- Merge from trunk up to r45543
[reactos.git] / dll / win32 / gdi32 / misc / stubs.c
index f7a15c2..19e1e77 100644 (file)
@@ -1,6 +1,5 @@
-/* $Id$
- *
- * reactos/lib/gdi32/misc/stubs.c
+/*
+ * dll/win32/gdi32/misc/stubs.c
  *
  * GDI32.DLL Stubs
  *
@@ -10,6 +9,7 @@
  */
 
 #include "precomp.h"
+#include <debug.h>
 
 #define SIZEOF_DEVMODEA_300 124
 #define SIZEOF_DEVMODEA_400 148
 #define SIZEOF_DEVMODEW_400 212
 #define SIZEOF_DEVMODEW_500 220
 
-#define UNIMPLEMENTED DbgPrint("GDI32: %s is unimplemented, please try again later.\n", __FUNCTION__);
-
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-PtInRegion(IN HRGN hrgn,
-           int x,
-           int y)
-{
-    /* FIXME some stuff at user mode need be fixed */
-    return NtGdiPtInRegion(hrgn,x,y);
-}
-
-/*
- * @unimplemented
- */
-BOOL
-WINAPI
-RectInRegion(HRGN hrgn,
-             LPCRECT prcl)
-{
-    /* FIXME some stuff at user mode need be fixed */
-    return NtGdiRectInRegion(hrgn, (LPRECT) prcl);
-}
-
 /*
  * @unimplemented
  */
@@ -69,8 +41,6 @@ SaveDC(IN HDC hdc)
     return NtGdiSaveDC(hdc);
 }
 
-
-
 /*
  * @implemented
  */
@@ -196,8 +166,6 @@ EnumObjects(HDC hdc,
     return Result;
 }
 
-
-
 /*
  * @implemented
  */
@@ -212,7 +180,6 @@ GetBoundsRect(
     return NtGdiGetBoundsRect(hdc,lprcBounds,flags & DCB_RESET);
 }
 
-
 /*
  * @unimplemented
  */
@@ -842,15 +809,16 @@ GdiArtificialDecrementDriver(LPWSTR pDriverName,BOOL unknown)
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL
 WINAPI
 GdiCleanCacheDC(HDC hdc)
 {
-       UNIMPLEMENTED;
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
+   if (GDI_HANDLE_GET_TYPE(hdc) == GDILoObjType_LO_DC_TYPE)
+      return TRUE;
+   SetLastError(ERROR_INVALID_HANDLE);
+   return FALSE;
 }
 
 /*
@@ -893,7 +861,7 @@ GdiConvertEnhMetaFile(HENHMETAFILE hmf)
  */
 BOOL
 WINAPI
-GdiDrawStream(HDC dc, ULONG l, VOID *v)
+GdiDrawStream(HDC dc, ULONG l, VOID *v) // See Bug 4784
 {
     UNIMPLEMENTED;
     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
@@ -967,15 +935,25 @@ GdiIsPlayMetafileDC(HDC hDC)
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL
 WINAPI
 GdiValidateHandle(HGDIOBJ hobj)
 {
-    UNIMPLEMENTED;
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return 0;
+  PGDI_TABLE_ENTRY Entry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hobj);
+  if ( (Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0 &&
+       ( (Entry->Type << GDI_ENTRY_UPPER_SHIFT) & GDI_HANDLE_TYPE_MASK ) == 
+                                                                   GDI_HANDLE_GET_TYPE(hobj) )
+  {
+    HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
+    if(pid == NULL || pid == CurrentProcessId)
+    {
+      return TRUE;
+    }
+  }
+  return FALSE;
+
 }
 
 /*
@@ -1561,33 +1539,6 @@ GdiResetDCEMF(HANDLE SpoolFileHandle,
     return 0;
 }
 
-
-/*
- * @unimplemented
- */
-INT
-WINAPI
-CombineRgn(HRGN  hDest,
-           HRGN  hSrc1,
-           HRGN  hSrc2,
-           INT  CombineMode)
-{
-    /* FIXME some part should be done in user mode */
-    return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode);
-}
-
-/*
- * @unimplemented
- */
-ULONG WINAPI
-XLATEOBJ_iXlate(XLATEOBJ *XlateObj,
-                ULONG Color)
-{
-    UNIMPLEMENTED;
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return 0;
-}
-
 /*
  * @unimplemented
  */
@@ -1615,8 +1566,6 @@ GdiPlayEMF(LPWSTR pwszPrinterName,
     return 0;
 }
 
-
-
 /*
  * @unimplemented
  */
@@ -1640,29 +1589,6 @@ VOID WINAPI GdiInitializeLanguagePack(DWORD InitParam)
     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
 }
 
-
-/*
- * @implemented
- */
-INT
-WINAPI
-ExcludeClipRect(IN HDC hdc, IN INT xLeft, IN INT yTop, IN INT xRight, IN INT yBottom)
-{
-    /* FIXME some part need be done on user mode size */
-    return NtGdiExcludeClipRect(hdc, xLeft, yTop, xRight, yBottom);
-}
-
-/*
- * @implemented
- */
-INT
-WINAPI
-ExtSelectClipRgn( IN HDC hdc, IN HRGN hrgn, IN INT iMode)
-{
-    /* FIXME some part need be done on user mode size */
-    return NtGdiExtSelectClipRgn(hdc,hrgn, iMode);
-}
-
 /*
  * @implemented
  */
@@ -1680,7 +1606,6 @@ GdiGradientFill(
     return NtGdiGradientFill(hdc, pVertex, nVertex, pMesh, nMesh, ulMode);
 }
 
-
 /*
  * @implemented
  */
@@ -1775,138 +1700,6 @@ GetFontData(HDC hdc,
     return NtGdiGetFontData(hdc, dwTable, dwOffset, lpvBuffer, cbData);
 }
 
-
-/*
- * @implemented
- *
- */
-DWORD
-WINAPI
-GetRegionData(HRGN hrgn,
-              DWORD nCount,
-              LPRGNDATA lpRgnData)
-{
-    if (!lpRgnData)
-    {
-        nCount = 0;
-    }
-
-    return NtGdiGetRegionData(hrgn,nCount,lpRgnData);
-}
-
-
-/*
- * @implemented
- *
- */
-INT
-WINAPI
-GetRgnBox(HRGN hrgn,
-          LPRECT prcOut)
-{
-#if 0
-  PRGN_ATTR Rgn_Attr;
-  if (!GdiGetHandleUserData((HGDIOBJ) hRgn, GDI_OBJECT_TYPE_REGION, (PVOID) &Rgn_Attr))
-     return NtGdiGetRgnBox(hrgn, prcOut);
-  if (Rgn_Attr->Flags == NULLREGION)
-  {
-     prcOut->left   = 0;
-     prcOut->top    = 0;
-     prcOut->right  = 0;
-     prcOut->bottom = 0;
-  }
-  else
-  {
-     if (Rgn_Attr->Flags != SIMPLEREGION) return NtGdiGetRgnBox(hrgn, prcOut);
-     *prcOut = Rgn_Attr->Rect;
-  }
-  return Rgn_Attr->Flags;
-#endif
-  return NtGdiGetRgnBox(hrgn, prcOut);
-}
-
-
-/*
- * @implemented
- *
- */
-INT
-WINAPI
-OffsetRgn( HRGN hrgn,
-          int nXOffset,
-          int nYOffset)
-{
-    /* FIXME some part are done in user mode */
-    return NtGdiOffsetRgn(hrgn,nXOffset,nYOffset);
-}
-
-/*
- * @implemented
- */
-INT
-WINAPI
-IntersectClipRect(HDC hdc,
-                  int nLeftRect,
-                  int nTopRect,
-                  int nRightRect,
-                  int nBottomRect)
-{
-#if 0
-// Handle something other than a normal dc object.
-  if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
-  {
-    if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
-      return MFDRV_IntersectClipRect( hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
-    else
-    {
-      PLDC pLDC = GdiGetLDC(hdc);
-      if ( pLDC )
-      {
-         if (pLDC->iType != LDC_EMFLDC || EMFDRV_IntersectClipRect( hdc, nLeftRect, nTopRect, nRightRect, nBottomRect))
-             return NtGdiIntersectClipRect(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
-      }
-      else
-        SetLastError(ERROR_INVALID_HANDLE);
-      return 0;
-    }
-  }
-#endif
-    return NtGdiIntersectClipRect(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
-}
-
-/*
- * @implemented
- */
-INT
-WINAPI
-OffsetClipRgn(HDC hdc,
-              int nXOffset,
-              int nYOffset)
-{
-#if 0
-// Handle something other than a normal dc object.
-  if (GDI_HANDLE_GET_TYPE(hdc) != GDI_OBJECT_TYPE_DC)
-  {
-    if (GDI_HANDLE_GET_TYPE(hdc) == GDI_OBJECT_TYPE_METADC)
-      return MFDRV_OffsetClipRgn( hdc, nXOffset, nYOffset );
-    else
-    {
-      PLDC pLDC = GdiGetLDC(hdc);
-      if ( !pLDC )
-      {
-         SetLastError(ERROR_INVALID_HANDLE);
-         return 0;
-      }
-      if (pLDC->iType == LDC_EMFLDC && !EMFDRV_OffsetClipRgn( hdc, nXOffset, nYOffset ))
-         return 0;
-      return NtGdiOffsetClipRgn( hdc,  nXOffset,  nYOffset);
-    }
-  }
-#endif
-  return NtGdiOffsetClipRgn( hdc,  nXOffset,  nYOffset);
-}
-
-
 INT
 WINAPI
 NamedEscape(HDC hdc,
@@ -1924,8 +1717,6 @@ NamedEscape(HDC hdc,
     return NtGdiExtEscape(NULL,pDriver,wcslen(pDriver),iEsc,cjIn,pjIn,cjOut,pjOut);
 }
 
-
-
 /*
  * @unimplemented
  */