gdi32: Implement EMFDRV_SelectPalette.
This commit is contained in:
parent
51c28a1493
commit
2820682202
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -464,6 +464,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
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue