Commit in reactos on MAIN
include/win32k/ntuser.h+31.126 -> 1.127
lib/gdi32/misc/stubs.c+1-551.59 -> 1.60
lib/gdi32/objects/dc.c+611.32 -> 1.33
subsys/win32k/include/intgdi.h+61.11 -> 1.12
subsys/win32k/ntuser/misc.c+15-11.62 -> 1.63
subsys/win32k/objects/dc.c+233-11.131 -> 1.132
+319-57
6 modified files
implemented GetDCBrushColor(), SetDCBrushColor(), GetDCPenColor() and SetDCPenColor(). they're UNTESTED so far!

reactos/include/win32k
ntuser.h 1.126 -> 1.127
diff -u -r1.126 -r1.127
--- ntuser.h	15 Apr 2004 23:36:02 -0000	1.126
+++ ntuser.h	25 Apr 2004 20:05:29 -0000	1.127
@@ -183,6 +183,9 @@
   DWORD Param,
   DWORD Routine);
 
+#define TWOPARAM_ROUTINE_SETDCPENCOLOR      0x45
+#define TWOPARAM_ROUTINE_SETDCBRUSHCOLOR    0x46
+#define TWOPARAM_ROUTINE_GETDCCOLOR         0x47
 #define TWOPARAM_ROUTINE_GETWINDOWRGNBOX    0x48
 #define TWOPARAM_ROUTINE_GETWINDOWRGN       0x49
 #define TWOPARAM_ROUTINE_SETMENUBARHEIGHT   0x50

reactos/lib/gdi32/misc
stubs.c 1.59 -> 1.60
diff -u -r1.59 -r1.60
--- stubs.c	25 Apr 2004 16:40:39 -0000	1.59
+++ stubs.c	25 Apr 2004 20:05:30 -0000	1.60
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.59 2004/04/25 16:40:39 weiden Exp $
+/* $Id: stubs.c,v 1.60 2004/04/25 20:05:30 weiden Exp $
  *
  * reactos/lib/gdi32/misc/stubs.c
  *
@@ -2288,32 +2288,6 @@
 /*
  * @unimplemented
  */
-COLORREF 
-STDCALL
-GetDCBrushColor(
-	HDC hdc
-)
-{
-	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-	return 0;
-}
-
-/*
- * @unimplemented
- */
-COLORREF 
-STDCALL
-GetDCPenColor(
-	HDC hdc
-)
-{
-	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-	return 0;
-}
-
-/*
- * @unimplemented
- */
 DWORD 
 STDCALL
 GetFontUnicodeRanges(
@@ -2549,34 +2523,6 @@
 /*
  * @unimplemented
  */
-COLORREF 
-STDCALL
-SetDCBrushColor(
-	HDC hdc,
-	COLORREF crColor
-)
-{
-	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-	return 0;
-}
-
-/*
- * @unimplemented
- */
-COLORREF 
-STDCALL
-SetDCPenColor(
-	HDC hdc,
-	COLORREF crColor
-)
-{
-	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-	return 0;
-}
-
-/*
- * @unimplemented
- */
 DWORD 
 STDCALL
 SetLayout(

reactos/lib/gdi32/objects
dc.c 1.32 -> 1.33
diff -u -r1.32 -r1.33
--- dc.c	25 Apr 2004 15:52:31 -0000	1.32
+++ dc.c	25 Apr 2004 20:05:30 -0000	1.33
@@ -11,6 +11,18 @@
 #define NDEBUG
 #include <debug.h>
 
+#define NtUserGetDCBrushColor(hbr) \
+  (COLORREF)NtUserCallTwoParam((DWORD)(hbr), OBJ_BRUSH, TWOPARAM_ROUTINE_GETDCCOLOR)
+
+#define NtUserGetDCPenColor(hbr) \
+  (COLORREF)NtUserCallTwoParam((DWORD)(hbr), OBJ_PEN, TWOPARAM_ROUTINE_GETDCCOLOR)
+
+#define NtUserSetDCBrushColor(hbr, crColor) \
+  (COLORREF)NtUserCallTwoParam((DWORD)(hbr), (DWORD)crColor, TWOPARAM_ROUTINE_SETDCBRUSHCOLOR)
+
+#define NtUserSetDCPenColor(hbr, crColor) \
+  (COLORREF)NtUserCallTwoParam((DWORD)(hbr), (DWORD)crColor, TWOPARAM_ROUTINE_SETDCPENCOLOR)
+
 /*
  * @implemented
  */
@@ -1059,3 +1071,52 @@
   return NtGdiPtVisible(hdc, X, Y);
 }
 
+/*
+ * @implemented
+ */
+COLORREF 
+STDCALL
+GetDCBrushColor(
+	HDC hdc
+)
+{
+  return NtUserGetDCBrushColor(hdc);
+}
+
+/*
+ * @implemented
+ */
+COLORREF 
+STDCALL
+GetDCPenColor(
+	HDC hdc
+)
+{
+  return NtUserGetDCPenColor(hdc);
+}
+
+/*
+ * @implemented
+ */
+COLORREF 
+STDCALL
+SetDCBrushColor(
+	HDC hdc,
+	COLORREF crColor
+)
+{
+  return NtUserSetDCBrushColor(hdc, crColor);
+}
+
+/*
+ * @implemented
+ */
+COLORREF 
+STDCALL
+SetDCPenColor(
+	HDC hdc,
+	COLORREF crColor
+)
+{
+  return NtUserSetDCPenColor(hdc, crColor);
+}

reactos/subsys/win32k/include
intgdi.h 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- intgdi.h	24 Apr 2004 14:21:36 -0000	1.11
+++ intgdi.h	25 Apr 2004 20:05:30 -0000	1.12
@@ -121,6 +121,12 @@
                PUNICODE_STRING Output,
                CONST PDEVMODEW InitData);
 
+COLORREF FASTCALL
+IntGetDCColor(HDC hDC, ULONG Object);
+
+COLORREF FASTCALL
+IntSetDCColor(HDC hDC, ULONG Object, COLORREF Color);
+
 /* Coord functions */
 
 BOOL FASTCALL

reactos/subsys/win32k/ntuser
misc.c 1.62 -> 1.63
diff -u -r1.62 -r1.63
--- misc.c	15 Apr 2004 23:36:03 -0000	1.62
+++ misc.c	25 Apr 2004 20:05:30 -0000	1.63
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.62 2004/04/15 23:36:03 weiden Exp $
+/* $Id: misc.c,v 1.63 2004/04/25 20:05:30 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -18,6 +18,8 @@
 #include <include/menu.h>
 #include <include/painting.h>
 #include <include/dce.h>
+#include <include/inteng.h>
+#include <include/intgdi.h>
 #include <include/mouse.h>
 #include <include/winsta.h>
 #include <include/caret.h>
@@ -208,6 +210,18 @@
   
   switch(Routine)
   {
+    case TWOPARAM_ROUTINE_SETDCPENCOLOR:
+    {
+      return (DWORD)IntSetDCColor((HDC)Param1, OBJ_PEN, (COLORREF)Param2);
+    }
+    case TWOPARAM_ROUTINE_SETDCBRUSHCOLOR:
+    {
+      return (DWORD)IntSetDCColor((HDC)Param1, OBJ_BRUSH, (COLORREF)Param2);
+    }
+    case TWOPARAM_ROUTINE_GETDCCOLOR:
+    {
+      return (DWORD)IntGetDCColor((HDC)Param1, (ULONG)Param2);
+    }
     case TWOPARAM_ROUTINE_GETWINDOWRGNBOX:
     {
       DWORD Ret;

reactos/subsys/win32k/objects
dc.c 1.131 -> 1.132
diff -u -r1.131 -r1.132
--- dc.c	25 Apr 2004 15:31:43 -0000	1.131
+++ dc.c	25 Apr 2004 20:05:30 -0000	1.132
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: dc.c,v 1.131 2004/04/25 15:31:43 weiden Exp $
+/* $Id: dc.c,v 1.132 2004/04/25 20:05:30 weiden Exp $
  *
  * DC.C - Device context functions
  *
@@ -2221,4 +2221,236 @@
    return SurfGDI == (PSURFGDI)AccessInternalObject((ULONG) PrimarySurface.Handle) ? TRUE : FALSE;
 }
 
+/*
+ * Returns the color of the brush or pen that is currently selected into the DC.
+ * This function is called from GetDCBrushColor() and GetDCPenColor()
+ */
+COLORREF FASTCALL
+IntGetDCColor(HDC hDC, ULONG Object)
+{
+  COLORREF Result;
+  DC *dc;
+  PPALGDI PalGDI;
+  PGDIBRUSHOBJ pen;
+  PGDIBRUSHOBJ brush;
+  XLATEOBJ *XlateObj;
+  HPALETTE Pal;
+  USHORT Mode;
+  ULONG iColor;
+  
+  if(!(dc = DC_LockDc(hDC)))
+  {
+    SetLastWin32Error(ERROR_INVALID_HANDLE);
+    return CLR_INVALID;
+  }
+  
+  switch(Object)
+  {
+    case OBJ_PEN:
+    {
+      if(!(pen = PENOBJ_LockPen(dc->w.hPen)))
+      {
+        DC_UnlockDc(hDC);
+        return CLR_INVALID;
+      }
+      if(!(pen->flAttrs & GDIBRUSH_IS_SOLID))
+      {
+        /* FIXME - just bail here? */
+        PENOBJ_UnlockPen(dc->w.hPen);
+        DC_UnlockDc(hDC);
+        return CLR_INVALID;
+      }
+      iColor = pen->BrushObject.iSolidColor;
+      PENOBJ_UnlockPen(dc->w.hPen);
+      break;
+    }
+    case OBJ_BRUSH:
+    {
+      if(!(brush = BRUSHOBJ_LockBrush(dc->w.hBrush)))
+      {
+        DC_UnlockDc(hDC);
+        return CLR_INVALID;
+      }
+      if(!(brush->flAttrs & GDIBRUSH_IS_SOLID))
+      {
+        /* FIXME - just bail here? */
+        BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+        DC_UnlockDc(hDC);
+        return CLR_INVALID;
+      }
+      iColor = brush->BrushObject.iSolidColor;
+      BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+      break;
+    }
+    default:
+    {
+      DC_UnlockDc(hDC);
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      return CLR_INVALID;
+    }
+  }
+  
+  /* translate the color into RGB */
+  
+  if(dc->w.hPalette)
+    Pal = dc->w.hPalette;
+  else
+    Pal = NtGdiGetStockObject(DEFAULT_PALETTE);
+  
+  Result = CLR_INVALID;
+  
+  if((PalGDI = PALETTE_LockPalette(dc->w.hPalette)))
+  {
+    Mode = PalGDI->Mode;
+    PALETTE_UnlockPalette(dc->w.hPalette);
+    XlateObj = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, Pal);
+    if(XlateObj)
+    {
+      Result = XLATEOBJ_iXlate(XlateObj, iColor);
+      EngDeleteXlate(XlateObj);
+    }
+  }
+  
+  DC_UnlockDc(hDC);
+  return Result;
+}
+
+/*
+ * Changes the color of the brush or pen that is currently selected into the DC.
+ * This function is called from SetDCBrushColor() and SetDCPenColor()
+ */
+COLORREF FASTCALL
+IntSetDCColor(HDC hDC, ULONG Object, COLORREF Color)
+{
+  COLORREF Result;
+  DC *dc;
+  PPALGDI PalGDI;
+  PGDIBRUSHOBJ pen;
+  PGDIBRUSHOBJ brush;
+  XLATEOBJ *XlateObj;
+  HPALETTE Pal;
+  USHORT Mode;
+  ULONG iColor;
+  
+  if(Color == CLR_INVALID)
+  {
+    SetLastWin32Error(ERROR_INVALID_PARAMETER);
+    return CLR_INVALID;
+  }
+  
+  if(!(dc = DC_LockDc(hDC)))
+  {
+    SetLastWin32Error(ERROR_INVALID_HANDLE);
+    return CLR_INVALID;
+  }
+  
+  switch(Object)
+  {
+    case OBJ_PEN:
+    {
+      if(!(pen = PENOBJ_LockPen(dc->w.hPen)))
+      {
+        DC_UnlockDc(hDC);
+        return CLR_INVALID;
+      }
+      if(!(pen->flAttrs & GDIBRUSH_IS_SOLID))
+      {
+        /* FIXME - just bail here? */
+        PENOBJ_UnlockPen(dc->w.hPen);
+        DC_UnlockDc(hDC);
+        return CLR_INVALID;
+      }
+      
+      /* save old color index, translate it to RGB later */
+      iColor = pen->BrushObject.iSolidColor;
+      
+      if(!(PalGDI = PALETTE_LockPalette(dc->w.hPalette)))
+      {
+        PENOBJ_UnlockPen(dc->w.hPen);
+        DC_UnlockDc(hDC);
+        return CLR_INVALID;
+      }
+      Mode = PalGDI->Mode;
+      PALETTE_UnlockPalette(dc->w.hPalette);
+      if(!(XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, dc->w.hPalette, NULL)))
+      {
+        PENOBJ_UnlockPen(dc->w.hPen);
+        DC_UnlockDc(hDC);
+        return CLR_INVALID;
+      }
+      pen->BrushObject.iSolidColor = XLATEOBJ_iXlate(XlateObj, (ULONG)Color);
+      EngDeleteXlate(XlateObj);
+      PENOBJ_UnlockPen(dc->w.hPen);
+      break;
+    }
+    case OBJ_BRUSH:
+    {
+      if(!(brush = BRUSHOBJ_LockBrush(dc->w.hBrush)))
+      {
+        DC_UnlockDc(hDC);
+        return CLR_INVALID;
+      }
+      if(!(brush->flAttrs & GDIBRUSH_IS_SOLID))
+      {
+        /* FIXME - just bail here? */
+        BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+        DC_UnlockDc(hDC);
+        return CLR_INVALID;
+      }
+      
+      /* save old color index, translate it to RGB later */
+      iColor = brush->BrushObject.iSolidColor;
+      
+      if(!(PalGDI = PALETTE_LockPalette(dc->w.hPalette)))
+      {
+        PENOBJ_UnlockPen(dc->w.hPen);
+        DC_UnlockDc(hDC);
+        return CLR_INVALID;
+      }
+      Mode = PalGDI->Mode;
+      PALETTE_UnlockPalette(dc->w.hPalette);
+      if(!(XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, dc->w.hPalette, NULL)))
+      {
+        PENOBJ_UnlockPen(dc->w.hPen);
+        DC_UnlockDc(hDC);
+        return CLR_INVALID;
+      }
+      brush->BrushObject.iSolidColor = XLATEOBJ_iXlate(XlateObj, (ULONG)Color);
+      EngDeleteXlate(XlateObj);
+      BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+      break;
+    }
+    default:
+    {
+      DC_UnlockDc(hDC);
+      SetLastWin32Error(ERROR_INVALID_PARAMETER);
+      return CLR_INVALID;
+    }
+  }
+  
+  /* translate the old color into RGB */
+  
+  if(dc->w.hPalette)
+    Pal = dc->w.hPalette;
+  else
+    Pal = NtGdiGetStockObject(DEFAULT_PALETTE);
+  
+  Result = CLR_INVALID;
+  
+  if((PalGDI = PALETTE_LockPalette(dc->w.hPalette)))
+  {
+    Mode = PalGDI->Mode;
+    PALETTE_UnlockPalette(dc->w.hPalette);
+    XlateObj = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, Pal);
+    if(XlateObj)
+    {
+      Result = XLATEOBJ_iXlate(XlateObj, iColor);
+      EngDeleteXlate(XlateObj);
+    }
+  }
+  
+  DC_UnlockDc(hDC);
+  return Result;
+}
+
 /* EOF */
CVSspam 0.2.8