SetDC{Pen|Brush}Color

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Changelog:

    Ulrich Czekalla ulrich@xxxxxxxxxxxxxxx
    Implement SetDCPenColor and SetDCBrushColor
Index: dlls/gdi/driver.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/driver.c,v
retrieving revision 1.28
diff -u -w -r1.28 driver.c
--- dlls/gdi/driver.c	4 Oct 2003 03:08:25 -0000	1.28
+++ dlls/gdi/driver.c	3 Nov 2003 18:23:16 -0000
@@ -157,7 +157,9 @@
     GET_FUNC(SetBitmapBits);
     GET_FUNC(SetBkColor);
     GET_FUNC(SetBkMode);
+    GET_FUNC(SetDCBrushColor);
     GET_FUNC(SetDCOrg);
+    GET_FUNC(SetDCPenColor);
     GET_FUNC(SetDIBColorTable);
     GET_FUNC(SetDIBits);
     GET_FUNC(SetDIBitsToDevice);
Index: dlls/gdi/gdi32.spec
===================================================================
RCS file: /home/wine/wine/dlls/gdi/gdi32.spec,v
retrieving revision 1.30
diff -u -w -r1.30 gdi32.spec
--- dlls/gdi/gdi32.spec	12 Aug 2003 20:42:19 -0000	1.30
+++ dlls/gdi/gdi32.spec	3 Nov 2003 18:23:16 -0000
@@ -350,6 +350,7 @@
 @ stdcall SetColorAdjustment(long ptr)
 @ stdcall SetColorSpace(long long)
 @ stdcall SetDCBrushColor(long long)
+@ stdcall SetDCPenColor(long long)
 @ stdcall SetDIBColorTable(long long long ptr)
 @ stdcall SetDIBits(long long long long ptr ptr long)
 @ stdcall SetDIBitsToDevice(long long long long long long long long long ptr ptr long)
Index: dlls/gdi/enhmfdrv/init.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/enhmfdrv/init.c,v
retrieving revision 1.26
diff -u -w -r1.26 init.c
--- dlls/gdi/enhmfdrv/init.c	22 Oct 2003 03:02:08 -0000	1.26
+++ dlls/gdi/enhmfdrv/init.c	3 Nov 2003 18:23:17 -0000
@@ -116,7 +116,9 @@
     NULL,                            /* pSetBitmapBits */
     EMFDRV_SetBkColor,               /* pSetBkColor */
     EMFDRV_SetBkMode,                /* pSetBkMode */
+    NULL,                            /* pSetDCBrushColor */
     NULL,                            /* pSetDCOrg */
+    NULL,                            /* pSetDCPenColor */
     NULL,                            /* pSetDIBColorTable */
     NULL,                            /* pSetDIBits */
     EMFDRV_SetDIBitsToDevice,        /* pSetDIBitsToDevice */
Index: dlls/gdi/mfdrv/init.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/mfdrv/init.c,v
retrieving revision 1.25
diff -u -w -r1.25 init.c
--- dlls/gdi/mfdrv/init.c	4 Oct 2003 03:08:25 -0000	1.25
+++ dlls/gdi/mfdrv/init.c	3 Nov 2003 18:23:17 -0000
@@ -117,7 +117,9 @@
     NULL,                            /* pSetBitmapBits */
     MFDRV_SetBkColor,                /* pSetBkColor */
     MFDRV_SetBkMode,                 /* pSetBkMode */
+    NULL,                            /* pSetDCBrushColor*/
     NULL,                            /* pSetDCOrg */
+    NULL,                            /* pSetDCPenColor*/
     NULL,                            /* pSetDIBColorTable */
     NULL,                            /* pSetDIBits */
     MFDRV_SetDIBitsToDevice,         /* pSetDIBitsToDevice */
Index: dlls/x11drv/x11drv.spec
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/x11drv.spec,v
retrieving revision 1.47
diff -u -w -r1.47 x11drv.spec
--- dlls/x11drv/x11drv.spec	8 Aug 2003 21:07:23 -0000	1.47
+++ dlls/x11drv/x11drv.spec	3 Nov 2003 18:23:23 -0000
@@ -46,7 +46,9 @@
 @ cdecl SelectPen(ptr long) X11DRV_SelectPen
 @ cdecl SetBitmapBits(long ptr long) X11DRV_SetBitmapBits
 @ cdecl SetBkColor(ptr long) X11DRV_SetBkColor
+@ cdecl SetDCBrushColor(ptr long) X11DRV_SetDCBrushColor
 @ cdecl SetDCOrg(ptr long long) X11DRV_SetDCOrg
+@ cdecl SetDCPenColor(ptr long) X11DRV_SetDCPenColor
 @ cdecl SetDIBColorTable(ptr long long ptr) X11DRV_SetDIBColorTable
 @ cdecl SetDIBits(ptr long long long ptr ptr long) X11DRV_SetDIBits
 @ cdecl SetDIBitsToDevice(ptr long long long long long long long long ptr ptr long) X11DRV_SetDIBitsToDevice
Index: graphics/x11drv/brush.c
===================================================================
RCS file: /home/wine/wine/graphics/x11drv/brush.c,v
retrieving revision 1.30
diff -u -w -r1.30 brush.c
--- graphics/x11drv/brush.c	31 Oct 2002 02:38:20 -0000	1.30
+++ graphics/x11drv/brush.c	3 Nov 2003 18:23:23 -0000
@@ -218,8 +218,6 @@
 }
 
 
-
-
 /***********************************************************************
  *           SelectBrush   (X11DRV.@)
  */
@@ -239,6 +237,8 @@
 	physDev->brush.pixmap = 0;
     }
     physDev->brush.style = logbrush.lbStyle;
+    if (hbrush == GetStockObject( DC_BRUSH ))
+        logbrush.lbColor = physDev->dc->dcBrushColor;
 
     switch(logbrush.lbStyle)
     {
@@ -281,4 +281,16 @@
 	break;
     }
     return hbrush;
+}
+
+
+/***********************************************************************
+ *           SetDCBrushColor (X11DRV.@)
+ */
+COLORREF X11DRV_SetDCBrushColor( X11DRV_PDEVICE *physDev, COLORREF crColor )
+{
+    if (GetCurrentObject(physDev->hdc, OBJ_BRUSH) == GetStockObject( DC_BRUSH ))
+        BRUSH_SelectSolidBrush( physDev, crColor );
+
+    return crColor;
 }
Index: graphics/x11drv/pen.c
===================================================================
RCS file: /home/wine/wine/graphics/x11drv/pen.c,v
retrieving revision 1.16
diff -u -w -r1.16 pen.c
--- graphics/x11drv/pen.c	25 Nov 2002 02:45:47 -0000	1.16
+++ graphics/x11drv/pen.c	3 Nov 2003 18:23:23 -0000
@@ -50,6 +50,8 @@
                                    dc->xformWorld2Vport.eM11);
     if (physDev->pen.width < 0) physDev->pen.width = -physDev->pen.width;
     if (physDev->pen.width == 1) physDev->pen.width = 0;  /* Faster */
+    if (hpen == GetStockObject( DC_PEN ))
+        logpen.lopnColor = dc->dcPenColor;
     physDev->pen.pixel = X11DRV_PALETTE_ToPhysical( physDev, logpen.lopnColor );
     switch(logpen.lopnStyle & PS_STYLE_MASK)
     {
@@ -78,4 +80,16 @@
 	break;
     }
     return hpen;
+}
+
+
+/***********************************************************************
+ *           SetDCPenColor (X11DRV.@)
+ */
+COLORREF X11DRV_SetDCPenColor( X11DRV_PDEVICE *physDev, COLORREF crColor )
+{
+    if (GetCurrentObject(physDev->hdc, OBJ_PEN) == GetStockObject( DC_PEN ))
+        physDev->pen.pixel = X11DRV_PALETTE_ToPhysical( physDev, crColor );
+
+    return crColor;
 }
Index: include/gdi.h
===================================================================
RCS file: /home/wine/wine/include/gdi.h,v
retrieving revision 1.85
diff -u -w -r1.85 gdi.h
--- include/gdi.h	4 Oct 2003 03:08:25 -0000	1.85
+++ include/gdi.h	3 Nov 2003 18:23:24 -0000
@@ -139,6 +139,8 @@
     WORD          backgroundMode;
     COLORREF      backgroundColor;
     COLORREF      textColor;
+    COLORREF      dcBrushColor;
+    COLORREF      dcPenColor;
     short         brushOrgX;
     short         brushOrgY;
 
@@ -256,7 +258,9 @@
     LONG     (*pSetBitmapBits)(HBITMAP,const void*,LONG);
     COLORREF (*pSetBkColor)(PHYSDEV,COLORREF);
     INT      (*pSetBkMode)(PHYSDEV,INT);
+    COLORREF (*pSetDCBrushColor)(PHYSDEV, COLORREF);
     DWORD    (*pSetDCOrg)(PHYSDEV,INT,INT);
+    COLORREF (*pSetDCPenColor)(PHYSDEV, COLORREF);
     UINT     (*pSetDIBColorTable)(PHYSDEV,UINT,UINT,const RGBQUAD*);
     INT      (*pSetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPCVOID,const BITMAPINFO*,UINT);
     INT      (*pSetDIBitsToDevice)(PHYSDEV,INT,INT,DWORD,DWORD,INT,INT,UINT,UINT,LPCVOID,
Index: include/wingdi.h
===================================================================
RCS file: /home/wine/wine/include/wingdi.h,v
retrieving revision 1.95
diff -u -w -r1.95 wingdi.h
--- include/wingdi.h	11 Sep 2003 20:40:57 -0000	1.95
+++ include/wingdi.h	3 Nov 2003 18:23:27 -0000
@@ -1830,8 +1830,10 @@
 #define DEFAULT_PALETTE     15
 #define SYSTEM_FIXED_FONT   16
 #define DEFAULT_GUI_FONT    17
+#define DC_BRUSH            18
+#define DC_PEN              19
 
-#define STOCK_LAST          17
+#define STOCK_LAST          19
 
 #define CLR_INVALID         0xffffffff
 /* Metafile header structure */
Index: objects/dc.c
===================================================================
RCS file: /home/wine/wine/objects/dc.c,v
retrieving revision 1.101
diff -u -w -r1.101 dc.c
--- objects/dc.c	4 Oct 2003 03:08:25 -0000	1.101
+++ objects/dc.c	3 Nov 2003 18:23:28 -0000
@@ -92,6 +92,8 @@
     dc->relAbsMode          = ABSOLUTE;
     dc->backgroundMode      = OPAQUE;
     dc->backgroundColor     = RGB( 255, 255, 255 );
+    dc->dcBrushColor        = RGB( 255, 255, 255 );
+    dc->dcPenColor          = RGB( 0, 0, 0 );
     dc->textColor           = RGB( 0, 0, 0 );
     dc->brushOrgX           = 0;
     dc->brushOrgY           = 0;
@@ -301,6 +303,8 @@
     newdc->backgroundMode   = dc->backgroundMode;
     newdc->backgroundColor  = dc->backgroundColor;
     newdc->textColor        = dc->textColor;
+    newdc->dcBrushColor     = dc->dcBrushColor;
+    newdc->dcPenColor       = dc->dcPenColor;
     newdc->brushOrgX        = dc->brushOrgX;
     newdc->brushOrgY        = dc->brushOrgY;
     newdc->textAlign        = dc->textAlign;
@@ -389,6 +393,8 @@
     dc->backgroundMode   = dcs->backgroundMode;
     dc->backgroundColor  = dcs->backgroundColor;
     dc->textColor        = dcs->textColor;
+    dc->dcBrushColor     = dcs->dcBrushColor;
+    dc->dcPenColor       = dcs->dcPenColor;
     dc->brushOrgX        = dcs->brushOrgX;
     dc->brushOrgY        = dcs->brushOrgY;
     dc->textAlign        = dcs->textAlign;
@@ -855,6 +861,8 @@
     COLORREF oldColor;
     DC * dc = DC_GetDCPtr( hdc );
 
+    TRACE("hdc=%p color=0x%08lx\n", hdc, color);
+
     if (!dc) return CLR_INVALID;
     oldColor = dc->backgroundColor;
     if (dc->funcs->pSetBkColor)
@@ -880,6 +888,8 @@
     COLORREF oldColor;
     DC * dc = DC_GetDCPtr( hdc );
 
+    TRACE(" hdc=%p color=0x%08lx\n", hdc, color);
+
     if (!dc) return CLR_INVALID;
     oldColor = dc->textColor;
     if (dc->funcs->pSetTextColor)
@@ -904,6 +914,9 @@
 {
     UINT prevAlign;
     DC *dc = DC_GetDCPtr( hdc );
+
+    TRACE("hdc=%p align=%d\n", hdc, align);
+
     if (!dc) return 0x0;
     if (dc->funcs->pSetTextAlign)
         prevAlign = dc->funcs->pSetTextAlign(dc->physDev, align);
@@ -1455,9 +1468,75 @@
  */
 COLORREF WINAPI SetDCBrushColor(HDC hdc, COLORREF crColor)
 {
-    FIXME("(%p, %08lx): stub\n", hdc, crColor);
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return CLR_INVALID;
+    DC *dc;
+    COLORREF oldClr = CLR_INVALID;
+
+    TRACE("hdc(%p) crColor(%08lx)\n", hdc, crColor);
+
+    dc = DC_GetDCPtr( hdc );
+    if (dc)
+    {
+        if (dc->funcs->pSetDCBrushColor)
+            crColor = dc->funcs->pSetDCBrushColor( dc->physDev, crColor );
+        else if (dc->hBrush == GetStockObject( DC_BRUSH ))
+        {
+            /* If DC_BRUSH is selected, update driver pen color */
+            HBRUSH hBrush = CreateSolidBrush( crColor );
+            dc->funcs->pSelectBrush( dc->physDev, hBrush );
+	    DeleteObject( hBrush );
+	}
+
+        if (crColor != CLR_INVALID)
+        {
+            oldClr = dc->dcBrushColor;
+            dc->dcBrushColor = crColor;
+        }
+
+        GDI_ReleaseObj( hdc );
+    }
+
+    return oldClr;
+}
+
+/***********************************************************************
+ *           SetDCPenColor    (GDI32.@)
+ *
+ * Sets the current device context (DC) pen color to the specified
+ * color value. If the device cannot represent the specified color
+ * value, the color is set to the nearest physical color.
+ *
+ */
+COLORREF WINAPI SetDCPenColor(HDC hdc, COLORREF crColor)
+{
+    DC *dc;
+    COLORREF oldClr = CLR_INVALID;
+
+    TRACE("hdc(%p) crColor(%08lx)\n", hdc, crColor);
+
+    dc = DC_GetDCPtr( hdc );
+    if (dc)
+    {
+        if (dc->funcs->pSetDCPenColor)
+            crColor = dc->funcs->pSetDCPenColor( dc->physDev, crColor );
+        else if (dc->hPen == GetStockObject( DC_PEN ))
+        {
+            /* If DC_PEN is selected, update the driver pen color */
+            LOGPEN logpen = { PS_SOLID, { 0, 0 }, crColor };
+            HPEN hPen = CreatePenIndirect( &logpen );
+            dc->funcs->pSelectPen( dc->physDev, hPen );
+	    DeleteObject( hPen );
+	}
+
+        if (crColor != CLR_INVALID)
+        {
+            oldClr = dc->dcPenColor;
+            dc->dcPenColor = crColor;
+        }
+
+        GDI_ReleaseObj( hdc );
+    }
+
+    return oldClr;
 }
 
 /***********************************************************************
Index: objects/gdiobj.c
===================================================================
RCS file: /home/wine/wine/objects/gdiobj.c,v
retrieving revision 1.90
diff -u -w -r1.90 gdiobj.c
--- objects/gdiobj.c	5 Sep 2003 23:15:42 -0000	1.90
+++ objects/gdiobj.c	3 Nov 2003 18:23:29 -0000
@@ -61,6 +61,8 @@
 static const LOGPEN BlackPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
 static const LOGPEN NullPen  = { PS_NULL,  { 0, 0 }, 0 };
 
+static const LOGBRUSH DCBrush = { BS_SOLID, RGB(255,255,255), 0 };
+static const LOGPEN DCPen     = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
 
 /* reserve one extra entry for the stock default bitmap */
 /* this is what Windows does too */
@@ -619,6 +621,8 @@
     stock_objects[SYSTEM_FIXED_FONT]   = create_stock_font( "SystemFixed", &deffonts->SystemFixedFont, hkey );
     stock_objects[DEFAULT_GUI_FONT]    = create_stock_font( "DefaultGui", &deffonts->DefaultGuiFont, hkey );
 
+    stock_objects[DC_BRUSH]     = CreateBrushIndirect( &DCBrush );
+    stock_objects[DC_PEN]       = CreatePenIndirect( &DCPen );
 
     /* clear the NOSYSTEM bit on all stock objects*/
     for (i = 0; i < NB_STOCK_OBJECTS; i++)

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux