Dmitry Timoshkov : gdi32: Implement EMFDRV_SelectPalette.
Alexandre Julliard
julliard at winehq.org
Wed May 7 13:28:12 CDT 2008
Module: wine
Branch: master
Commit: 2820682202886cb1fc438ab55b3c39f13baef9bf
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2820682202886cb1fc438ab55b3c39f13baef9bf
Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date: Wed May 7 20:35:04 2008 +0900
gdi32: Implement EMFDRV_SelectPalette.
---
dlls/gdi32/enhmfdrv/enhmetafiledrv.h | 1 +
dlls/gdi32/enhmfdrv/init.c | 2 +-
dlls/gdi32/enhmfdrv/objects.c | 55 ++++++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+), 1 deletions(-)
diff --git a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h
index f1c81a2..c00c653 100644
--- a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h
+++ b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h
@@ -122,6 +122,7 @@ extern HBRUSH EMFDRV_SelectBrush( PHYSDEV dev, HBRUSH handle ) DECLSPEC_HIDDEN
extern BOOL EMFDRV_SelectClipPath( PHYSDEV dev, INT iMode ) DECLSPEC_HIDDEN;
extern HFONT EMFDRV_SelectFont( PHYSDEV dev, HFONT handle, HANDLE gdiFont ) DECLSPEC_HIDDEN;
extern HPEN EMFDRV_SelectPen( PHYSDEV dev, HPEN handle ) DECLSPEC_HIDDEN;
+extern HPALETTE EMFDRV_SelectPalette( PHYSDEV dev, HPALETTE hPal, BOOL force ) DECLSPEC_HIDDEN;
extern INT EMFDRV_SetArcDirection( PHYSDEV dev, INT arcDirection ) DECLSPEC_HIDDEN;
extern COLORREF EMFDRV_SetBkColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern INT EMFDRV_SetBkMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
diff --git a/dlls/gdi32/enhmfdrv/init.c b/dlls/gdi32/enhmfdrv/init.c
index dafac60..de135d2 100644
--- a/dlls/gdi32/enhmfdrv/init.c
+++ b/dlls/gdi32/enhmfdrv/init.c
@@ -114,7 +114,7 @@ static const DC_FUNCTIONS EMFDRV_Funcs =
EMFDRV_SelectBrush, /* pSelectBrush */
EMFDRV_SelectClipPath, /* pSelectClipPath */
EMFDRV_SelectFont, /* pSelectFont */
- NULL, /* pSelectPalette */
+ EMFDRV_SelectPalette, /* pSelectPalette */
EMFDRV_SelectPen, /* pSelectPen */
EMFDRV_SetArcDirection, /* pSetArcDirection */
NULL, /* pSetBitmapBits */
diff --git a/dlls/gdi32/enhmfdrv/objects.c b/dlls/gdi32/enhmfdrv/objects.c
index c7ecd54..54c34bf 100644
--- a/dlls/gdi32/enhmfdrv/objects.c
+++ b/dlls/gdi32/enhmfdrv/objects.c
@@ -465,6 +465,61 @@ HPEN EMFDRV_SelectPen(PHYSDEV dev, HPEN hPen )
/******************************************************************
+ * EMFDRV_CreatePalette
+ */
+static DWORD EMFDRV_CreatePalette(PHYSDEV dev, HPALETTE hPal)
+{
+ WORD i;
+ struct {
+ EMRCREATEPALETTE hdr;
+ PALETTEENTRY entry[255];
+ } pal;
+
+ memset( &pal, 0, sizeof(pal) );
+
+ if (!GetObjectW( hPal, sizeof(pal.hdr.lgpl) + sizeof(pal.entry), &pal.hdr.lgpl ))
+ return 0;
+
+ for (i = 0; i < pal.hdr.lgpl.palNumEntries; i++)
+ pal.hdr.lgpl.palPalEntry[i].peFlags = 0;
+
+ pal.hdr.emr.iType = EMR_CREATEPALETTE;
+ pal.hdr.emr.nSize = sizeof(pal.hdr) + pal.hdr.lgpl.palNumEntries * sizeof(PALETTEENTRY);
+ pal.hdr.ihPal = EMFDRV_AddHandle( dev, hPal );
+
+ if (!EMFDRV_WriteRecord( dev, &pal.hdr.emr ))
+ pal.hdr.ihPal = 0;
+ return pal.hdr.ihPal;
+}
+
+/******************************************************************
+ * EMFDRV_SelectPalette
+ */
+HPALETTE EMFDRV_SelectPalette( PHYSDEV dev, HPALETTE hPal, BOOL force )
+{
+ EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev;
+ EMRSELECTPALETTE emr;
+ DWORD index;
+
+ if (hPal == GetStockObject( DEFAULT_PALETTE ))
+ index = DEFAULT_PALETTE | 0x80000000;
+ goto found;
+
+ if ((index = EMFDRV_FindObject( dev, hPal )) != 0)
+ goto found;
+
+ if (!(index = EMFDRV_CreatePalette( dev, hPal ))) return 0;
+ GDI_hdc_using_object( hPal, physDev->hdc );
+
+found:
+ emr.emr.iType = EMR_SELECTPALETTE;
+ emr.emr.nSize = sizeof(emr);
+ emr.ihPal = index;
+ return EMFDRV_WriteRecord( dev, &emr.emr ) ? hPal : 0;
+}
+
+
+/******************************************************************
* EMFDRV_GdiComment
*/
BOOL EMFDRV_GdiComment(PHYSDEV dev, UINT bytes, CONST BYTE *buffer)
More information about the wine-cvs
mailing list