Ignore:
Timestamp:
Oct 22, 1999, 8:11:51 PM (26 years ago)
Author:
sandervl
Message:

Lots of changes/fixes

File:
1 edited

Legend:

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

    r1351 r1405  
    1 /* $Id: dc.cpp,v 1.16 1999-10-18 11:59:57 sandervl Exp $ */
     1/* $Id: dc.cpp,v 1.17 1999-10-22 18:11:43 sandervl Exp $ */
    22
    33/*
     
    1313
    1414#include <odin.h>
    15 #include <odinwrap.h>
    16 #include <os2sel.h>
    1715
    1816#define INCL_WIN
     
    2018#define INCL_GREALL
    2119#define INCL_DEV
    22 #include <os2.h>
     20#include <os2wrap.h>
    2321#include <pmddi.h>
    2422#include <stdlib.h>
     23
    2524#include "win32type.h"
    2625#include <winconst.h>
    27 #include <wprocess.h>
    2826#include <misc.h>
    2927#include <win32wbase.h>
     
    3331#include "dcdata.h"
    3432
    35 ODINDEBUGCHANNEL(USER32-DC)
     33#define INCLUDED_BY_DC
     34#include "dc.h"
    3635
    3736#undef SEVERITY_ERROR
    3837#include <winerror.h>
    39 
    40 #ifndef OPEN32API
    41 #define OPEN32API _System
    42 #endif
    43 
    44 /*********************/
    45 typedef struct
    46 {
    47     HDC   hdc;
    48     BOOL  fErase;
    49     RECT  rcPaint;
    50     BOOL  fRestore;
    51     BOOL  IncUpdate;
    52     BYTE  rgbReserved[32];
    53 } PAINTSTRUCT_W, *PPAINTSTRUCT_W, *LPPAINTSTRUCT_W;
    54 
    55 #define PS_SOLID_W         0x00000000
    56 #define PS_DASH_W          0x00000001
    57 #define PS_DOT_W           0x00000002
    58 #define PS_DASHDOT_W       0x00000003
    59 #define PS_DASHDOTDOT_W    0x00000004
    60 #define PS_NULL_W          0x00000005
    61 #define PS_INSIDEFRAME_W   0x00000006
    62 #define PS_USERSTYLE_W     0x00000007
    63 #define PS_ALTERNATE_W     0x00000008
    64 #define PS_STYLE_MASK_W    0x0000000f
    65 
    66 typedef struct
    67 {
    68     UINT   lopnStyle;
    69     POINT  lopnWidth;
    70     ULONG  lopnColor;
    71 } LOGPEN_W, *LPLOGPEN_W;
    72 
    73 typedef struct tagEXTLOGPEN
    74 {
    75     DWORD elpPenStyle;
    76     DWORD elpWidth;
    77     DWORD elpBrushStyle;
    78     DWORD elpColor;
    79     DWORD elpNumEntries;
    80     DWORD elpStyleEntry[1];
    81 } EXTLOGPEN_W, *PEXTLOGPEN_W, *NPEXTLOGPEN_W, *LPEXTLOGPEN_W;
    82 
    83 typedef struct
    84 {
    85     UINT   lbStyle;
    86     ULONG  lbColor;
    87     INT    lbHatch;
    88 } LOGBRUSH_W, *LPLOGBRUSH_W;
    89 
    90 typedef struct _penobject
    91 {
    92    ULONG filler[9];
    93    union {
    94      struct {
    95        PEXTLOGPEN_W      pExtLogPen;
    96        LOGBRUSH_W        logbrush;
    97        LOGPEN_W          logpen;
    98      } ExtPen;
    99      struct {
    100        LOGPEN_W          logpen;
    101      } Pen;
    102    };
    103 } tPenObject, *pPenObject;
    104 
    105 /* DC Graphics Mode */
    106 #define GM_COMPATIBLE_W     1
    107 #define GM_ADVANCED_W       2
    108 
    109 #define DCX_WINDOW_W                    0x00000001L
    110 #define DCX_CACHE_W                     0x00000002L
    111 #define DCX_NORESETATTRS_W              0x00000004L
    112 #define DCX_CLIPCHILDREN_W              0x00000008L
    113 #define DCX_CLIPSIBLINGS_W              0x00000010L
    114 #define DCX_PARENTCLIP_W                0x00000020L
    115 #define DCX_EXCLUDERGN_W                0x00000040L
    116 #define DCX_INTERSECTRGN_W              0x00000080L
    117 #define DCX_EXCLUDEUPDATE_W             0x00000100L
    118 #define DCX_INTERSECTUPDATE_W           0x00000200L
    119 #define DCX_LOCKWINDOWUPDATE_W          0x00000400L
    120 #define DCX_VALIDATE_W                  0x00200000L
    121 
    122 #define RDW_INVALIDATE_W       0x0001
    123 #define RDW_INTERNALPAINT_W    0x0002
    124 #define RDW_ERASE_W            0x0004
    125 #define RDW_VALIDATE_W         0x0008
    126 #define RDW_NOINTERNALPAINT_W  0x0010
    127 #define RDW_NOERASE_W          0x0020
    128 #define RDW_NOCHILDREN_W       0x0040
    129 #define RDW_ALLCHILDREN_W      0x0080
    130 #define RDW_UPDATENOW_W        0x0100
    131 #define RDW_ERASENOW_W         0x0200
    132 #define RDW_FRAME_W            0x0400
    133 #define RDW_NOFRAME_W          0x0800
    134 
    135 typedef struct _RGNDATAHEADER_W {
    136     DWORD       dwSize;
    137     DWORD       iType;
    138     DWORD       nCount;
    139     DWORD       nRgnSize;
    140     RECT        rcBound;
    141 } RGNDATAHEADER_W, *LPRGNDATAHEADER_W;
    142 
    143 typedef struct _RGNDATA_W {
    144     RGNDATAHEADER_W     rdh;
    145     char                Buffer[1];
    146 } RGNDATA_W , *PRGNDATA_W , *LPRGNDATA_W ;
    147 
    148 
    149 /* Xform FLAGS */
    150 #define MWT_IDENTITY_W        1
    151 #define MWT_LEFTMULTIPLY_W    2
    152 #define MWT_RIGHTMULTIPLY_W   3
    153 
    154 /* Mapping Modes */
    155 #define MM_TEXT_W             1
    156 #define MM_LOMETRIC_W         2
    157 #define MM_HIMETRIC_W         3
    158 #define MM_LOENGLISH_W        4
    159 #define MM_HIENGLISH_W        5
    160 #define MM_TWIPS_W            6
    161 #define MM_ISOTROPIC_W        7
    162 #define MM_ANISOTROPIC_W      8
    163 
    164 #define RGN_OR_W              2
    165 
    166 /* Window scrolling */
    167 #define SW_SCROLLCHILDREN_W    0x0001
    168 #define SW_INVALIDATE_W        0x0002
    169 #define SW_ERASE_W             0x0004
    170 
    171 /*********************/
    172 
    173 BOOL    APIENTRY GpiEnableYInversion (HPS hps, LONG lHeight);
    174 LONG    APIENTRY GpiQueryYInversion (HPS hps);
    175 PVOID   APIENTRY GpiAllocateDCData (HPS GpiH, ULONG size);
    176 PVOID   APIENTRY GpiQueryDCData (HPS hps);
    177 HDC     OPEN32API HPSToHDC (HWND hwnd, HPS hps, HDC hdc, PVOID);
    178 void    OPEN32API DeleteHDC (HDC hdc);
    179 BOOL    OPEN32API _O32_EndPaint (HWND hwnd, const PAINTSTRUCT_W *lpps);
    180 int     OPEN32API _O32_GetUpdateRgn (HWND hwnd, HRGN hrgn, BOOL erase);
    181 ULONG   OPEN32API _O32_GetRegionData (HRGN hrgn, ULONG count, PRGNDATA_W pData);
    182 BOOL    OPEN32API _O32_DeleteObject (LHANDLE hgdiobj);
    183 int     OPEN32API _O32_ReleaseDC (HWND hwnd, HDC hdc);
    184 VOID    OPEN32API _O32_SetLastError( DWORD );
    185 BOOL    OPEN32API _O32_SetRectRgn (HRGN dest, int left, int top, int right, int bottom);
    186 int     OPEN32API _O32_CombineRgn (HRGN dest, HRGN src1, HRGN src2, int mode);
    187 HRGN    OPEN32API _O32_CreateRectRgn (int left, int top, int right, int bottom);
    18838
    18939#ifndef DEVESC_SETPS
     
    269119      case MM_ISOTROPIC_W  : flOptions = PU_LOMETRIC ; break;
    270120      default:
    271          _O32_SetLastError (ERROR_INVALID_PARAMETER);
     121         O32_SetLastError (ERROR_INVALID_PARAMETER);
    272122         return FALSE;
    273123   }
     
    294144      if (DevEscape(pHps->hdc ? pHps->hdc : pHps->hps, DEVESC_SETPS, 12, (PBYTE)data, 0, 0) == DEVESC_ERROR)
    295145      {
    296          _O32_SetLastError (ERROR_INVALID_PARAMETER);
     146         O32_SetLastError (ERROR_INVALID_PARAMETER);
    297147         return 0;
    298148      }
     
    614464
    615465      GpiSetBitmap (pHps->hps, NULL);
    616       _O32_DeleteObject (pHps->nullBitmapHandle);
     466      O32_DeleteObject (pHps->nullBitmapHandle);
    617467      GpiDestroyPS(pHps->hps);
    618468
     
    636486   if ( !lpps )
    637487   {
    638       _O32_SetLastError (ERROR_INVALID_PARAMETER);
     488      O32_SetLastError (ERROR_INVALID_PARAMETER);
    639489      return (HDC)NULLHANDLE;
    640490   }
    641491
    642    USHORT sel = RestoreOS2FS();
    643492   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    644493
     
    649498      if (!pHps)
    650499      {
    651          _O32_SetLastError (ERROR_INVALID_PARAMETER);
    652          SetFS(sel);
     500         O32_SetLastError (ERROR_INVALID_PARAMETER);
    653501         return (HDC)NULLHANDLE;
    654502      }
     
    699547   WINRECT_FROM_PMRECT(lpps->rcPaint, rect);
    700548
    701    SetFS(sel);
    702    _O32_SetLastError(0);
     549   O32_SetLastError(0);
    703550   return (HDC)pHps->hps;
    704551}
     
    711558      return TRUE;
    712559
    713    USHORT sel = RestoreOS2FS();
    714560   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    715561
     
    727573   else
    728574   {
    729        _O32_EndPaint (HWND_DESKTOP, pPaint);
     575       O32_EndPaint (HWND_DESKTOP, pPaint);
    730576   }
    731577
    732578exit:
    733    SetFS(sel);
    734    _O32_SetLastError(0);
     579   O32_SetLastError(0);
    735580   return TRUE;
    736581}
     
    740585   if (hwnd)
    741586   {
    742       _O32_SetLastError (ERROR_INVALID_HANDLE);
     587      O32_SetLastError (ERROR_INVALID_HANDLE);
    743588      return FALSE;
    744589   }
    745590
    746591   RECTL rectl;
    747    USHORT sel = RestoreOS2FS();
    748592   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    749593
    750594   BOOL updateRegionExists = WinQueryUpdateRect (hwnd, pRect ? &rectl : NULL);
    751595   if (!pRect) {
    752       SetFS(sel);
    753596      return (updateRegionExists);
    754597   }
     
    762605         if (!pHps)
    763606         {
    764             _O32_SetLastError (ERROR_INVALID_HANDLE);
    765             SetFS(sel);
     607            O32_SetLastError (ERROR_INVALID_HANDLE);
    766608            return FALSE;
    767609         }
     
    787629   }
    788630
    789    SetFS(sel);
    790631   return updateRegionExists;
    791632}
     
    793634int WIN32API GetUpdateRgn (HWND hwnd, HRGN hrgn, BOOL erase)
    794635{
    795    USHORT sel = RestoreOS2FS();
    796636   LONG Complexity;
    797637
    798    Complexity = _O32_GetUpdateRgn (hwnd, hrgn, FALSE);
     638   Complexity = O32_GetUpdateRgn (hwnd, hrgn, FALSE);
    799639   if (erase && (Complexity > NULLREGION_W)) {
    800640       Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    802642   }
    803643
    804    SetFS(sel);
    805644   return Complexity;
    806645}
     
    814653HDC WIN32API GetDCEx (HWND hwnd, HRGN hrgn, ULONG flags)
    815654{
    816    USHORT sel = RestoreOS2FS();
    817655   Win32BaseWindow *wnd = NULL;
    818656   HWND     hWindow;
     
    836674      hWindow = HWND_DESKTOP;
    837675
    838 dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x", hwnd, hrgn, flags, wnd));
     676   dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x", hwnd, hrgn, flags, wnd));
    839677
    840678   isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : wnd->isOwnDC())
    841679                 && !(flags & DCX_CACHE_W));
     680
    842681   if (isWindowOwnDC)
    843682   {
     
    857696
    858697         pHps->hdcType = TYPE_1;
    859          SetFS(sel);
    860698         return (HDC)hps;
    861699      }
     
    904742         goto error;
    905743
    906       BytesNeeded = _O32_GetRegionData (hrgn, 0, NULL);
     744      BytesNeeded = O32_GetRegionData (hrgn, 0, NULL);
    907745      RgnData = (PRGNDATA_W)_alloca (BytesNeeded);
    908746      if (RgnData == NULL)
    909747          goto error;
    910       _O32_GetRegionData (hrgn, BytesNeeded, RgnData);
     748      O32_GetRegionData (hrgn, BytesNeeded, RgnData);
    911749
    912750      i = RgnData->rdh.nCount;
     
    941779   GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF);
    942780
    943    SetFS(sel);
    944781   return (HDC)pHps->hps;
    945782
     
    960797      if (pHps->hrgnHDC) GpiDestroyRegion(pHps->hps, pHps->hrgnHDC);
    961798
    962       _O32_DeleteObject (pHps->nullBitmapHandle);
    963    }
    964    _O32_SetLastError (ERROR_INVALID_PARAMETER);
    965    SetFS(sel);
     799      O32_DeleteObject (pHps->nullBitmapHandle);
     800   }
     801   O32_SetLastError (ERROR_INVALID_PARAMETER);
    966802   return NULL;
    967803}
     
    979815int WIN32API ReleaseDC (HWND hwnd, HDC hdc)
    980816{
    981    USHORT sel = RestoreOS2FS();
    982817   BOOL isOwnDC = FALSE;
    983818   int rc;
     
    991826      rc = TRUE;
    992827   else
    993       rc = _O32_ReleaseDC (0, hdc);
    994 
    995    SetFS(sel);
     828      rc = O32_ReleaseDC (0, hdc);
     829
    996830   dprintf(("ReleaseDC %x %x", hwnd, hdc));
    997831   return (rc);
     
    1003837       return FALSE;
    1004838
    1005    USHORT sel = RestoreOS2FS();
    1006839   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
    1007840
     
    1017850#endif
    1018851
    1019    SetFS(sel);
    1020852   return (TRUE);
    1021853}
     
    1031863// RDW_UPDATENOW
    1032864
    1033 ODINFUNCTION4(BOOL,RedrawWindow,HWND,        hwnd,
    1034                                 const RECT*, pRect,
    1035                                 HRGN,        hrgn,
    1036                                 DWORD,       redraw)
     865BOOL WIN32API RedrawWindow(HWND hwnd, const RECT* pRect, HRGN hrgn, DWORD redraw)
    1037866{
    1038867   Win32BaseWindow *wnd;
     
    1040869   if (redraw & (RDW_FRAME_W | RDW_NOFRAME_W))
    1041870   {
    1042       _O32_SetLastError (ERROR_NOT_SUPPORTED);
     871      O32_SetLastError (ERROR_NOT_SUPPORTED);
    1043872      return FALSE;
    1044873   }
    1045 
    1046 //@@@PH   USHORT sel = RestoreOS2FS();
    1047 //@@@PH dprintf(("USER32: RedrawWindow %X, %X %X %X", hwnd, pRect, hrgn, redraw));
    1048874
    1049875   if (hwnd == NULLHANDLE)
     
    1056882         dprintf(("USER32:dc: RedrawWindow can't find desktop window %08xh\n",
    1057883                  hwnd));
    1058          _O32_SetLastError (ERROR_INVALID_PARAMETER);
    1059 //@@@PH         SetFS(sel);
     884         O32_SetLastError (ERROR_INVALID_PARAMETER);
    1060885         return FALSE;
    1061886      }
     
    1070895         dprintf(("USER32:dc: RedrawWindow can't find window %08xh\n",
    1071896                  hwnd));
    1072          _O32_SetLastError (ERROR_INVALID_PARAMETER);
    1073 //@@@PH         SetFS(sel);
     897         O32_SetLastError (ERROR_INVALID_PARAMETER);
    1074898         return FALSE;
    1075899      }
     
    1124948         goto error;
    1125949
    1126       BytesNeeded = _O32_GetRegionData (hrgn, 0, NULL);
     950      BytesNeeded = O32_GetRegionData (hrgn, 0, NULL);
    1127951      RgnData = (PRGNDATA_W)_alloca (BytesNeeded);
    1128952      if (RgnData == NULL)
    1129953          goto error;
    1130       _O32_GetRegionData (hrgn, BytesNeeded, RgnData);
     954      O32_GetRegionData (hrgn, BytesNeeded, RgnData);
    1131955
    1132956      pr = (PRECTL)(RgnData->Buffer);
     
    12071031
    12081032   if (!success)
    1209       _O32_SetLastError (ERROR_INVALID_PARAMETER);
    1210 
    1211 //@@@PH   SetFS(sel);
     1033      O32_SetLastError (ERROR_INVALID_PARAMETER);
     1034
    12121035   return (success);
    12131036}
     
    12151038BOOL WIN32API InvalidateRect (HWND hwnd, const RECT *pRect, BOOL erase)
    12161039{
    1217    USHORT sel = RestoreOS2FS();
    12181040//   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
    12191041   BOOL result;
     
    12271049                          (erase ? RDW_ERASE_W : 0) |
    12281050                          (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
    1229    SetFS(sel);
    12301051   return (result);
    12311052}
     
    12331054BOOL WIN32API InvalidateRgn (HWND hwnd, HRGN hrgn, BOOL erase)
    12341055{
    1235    USHORT sel = RestoreOS2FS();
    12361056//   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
    12371057   BOOL result;
     
    12451065                          (erase ? RDW_ERASE_W : 0) |
    12461066                          (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
    1247    SetFS(sel);
    12481067   return (result);
    12491068}
     
    12701089         rc = GpiQueryRegionRects (hps, hrgnPM, NULL, &rgnRect, Rcls);
    12711090
    1272          rc = _O32_SetRectRgn (hrgnWin, pRcl->xLeft,
     1091         rc = O32_SetRectRgn (hrgnWin, pRcl->xLeft,
    12731092                                        pRcl->xRight,
    12741093                                        height - pRcl->yTop,
     
    12791098            int i;
    12801099            HRGN temp;
    1281             temp = _O32_CreateRectRgn (0, 0, 1, 1);
     1100            temp = O32_CreateRectRgn (0, 0, 1, 1);
    12821101
    12831102            for (i = 1, pRcl++; rc && (i < rgnRect.crcReturned); i++, pRcl++)
    12841103            {
    1285               rc = _O32_SetRectRgn (temp, pRcl->xLeft,
     1104              rc = O32_SetRectRgn (temp, pRcl->xLeft,
    12861105                                          pRcl->xRight,
    12871106                                          height - pRcl->yTop,
    12881107                                          height - pRcl->yBottom);
    1289               rc &= _O32_CombineRgn (hrgnWin, hrgnWin, temp, RGN_OR_W);
     1108              rc &= O32_CombineRgn (hrgnWin, hrgnWin, temp, RGN_OR_W);
    12901109            }
    1291             _O32_DeleteObject (temp);
     1110            O32_DeleteObject (temp);
    12921111         }
    12931112         delete[] Rcls;
     
    13001119   else
    13011120   {
    1302       rc = _O32_SetRectRgn (hrgnWin, 0, 0, 0, 0);
     1121      rc = O32_SetRectRgn (hrgnWin, 0, 0, 0, 0);
    13031122   }
    13041123
     
    13101129                        const RECT *pClip, HRGN hrgnUpdate, LPRECT pRectUpdate)
    13111130{
    1312    USHORT sel = RestoreOS2FS();
    13131131   BOOL rc = TRUE;
    13141132
     
    13171135   if (!hDC)
    13181136   {
    1319       SetFS(sel);
    13201137      return (FALSE);
    13211138   }
     
    13271144   if ((hwnd == NULLHANDLE) || !wnd)
    13281145   {
    1329       SetFS(sel);
    13301146      return (FALSE);
    13311147   }
     
    14131229   if (lComplexity == RGN_ERROR)
    14141230   {
    1415       SetFS(sel);
    14161231      return (FALSE);
    14171232   }
     
    14311246      rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, height);
    14321247
    1433    SetFS(sel);
    14341248   return (rc);
    14351249}
     
    14391253BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip)
    14401254{
    1441  USHORT sel = RestoreOS2FS();
    14421255 Win32BaseWindow *window;
    14431256 APIRET  rc;
     
    14521265    if(!window) {
    14531266        dprintf(("ScrollWindow, window %x not found", hwnd));
    1454         SetFS(sel);
    14551267        return 0;
    14561268    }
     
    14971309                         NULL, scrollFlags);
    14981310
    1499     SetFS(sel);
    15001311    return (rc != RGN_ERROR);
    15011312}
     
    15051316                            HRGN hrgnUpdate, PRECT pRectUpdate, UINT scrollFlag)
    15061317{
    1507     USHORT sel = RestoreOS2FS();
    15081318    Win32BaseWindow *window;
    15091319    APIRET  rc;
     
    15161326    if(!window) {
    15171327        dprintf(("ScrollWindowEx, window %x not found", hwnd));
    1518         SetFS(sel);
    15191328        return 0;
    15201329    }
     
    15391348    if (lComplexity == RGN_ERROR)
    15401349    {
    1541         SetFS(sel);
    15421350        return (0);
    15431351    }
     
    15631371       if (rc == FALSE)
    15641372       {
    1565           SetFS(sel);
    15661373          return (0);
    15671374       }
     
    15841391    }
    15851392
    1586     SetFS(sel);
    15871393    return (regionType);
    15881394}
Note: See TracChangeset for help on using the changeset viewer.