/****************************************************************** * EMFDRV_SelectPen */ HPEN EMFDRV_SelectPen(PHYSDEV dev, HPEN hPen, const struct brush_pattern *pattern ) { EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev; EMRSELECTOBJECT emr; DWORD index; int i; if (physDev->restoring) return hPen; /* don't output SelectObject records during RestoreDC */ /* If the object is a stock pen object, do not need to create it. * See definitions in wingdi.h for range of stock pens. * We do however have to handle setting the higher order bit to * designate that this is a stock object. */ for (i = WHITE_PEN; i <= DC_PEN; i++) { if (hPen == GetStockObject(i)) { index = i | 0x80000000; goto found; } } if((index = EMFDRV_FindObject(dev, hPen)) != 0) goto found; if (!(index = EMFDRV_CreatePenIndirect(dev, hPen))) return 0; GDI_hdc_using_object(hPen, dev->hdc); found: emr.emr.iType = EMR_SELECTOBJECT; emr.emr.nSize = sizeof(emr); emr.ihObject = index; return EMFDRV_WriteRecord( dev, &emr.emr ) ? hPen : 0; }
/****************************************************************** * EMFDRV_SelectPalette */ HPALETTE EMFDRV_SelectPalette( PHYSDEV dev, HPALETTE hPal, BOOL force ) { EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev; EMRSELECTPALETTE emr; DWORD index; if (physDev->restoring) return hPal; /* don't output SelectObject records during RestoreDC */ 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, dev->hdc ); found: emr.emr.iType = EMR_SELECTPALETTE; emr.emr.nSize = sizeof(emr); emr.ihPal = index; return EMFDRV_WriteRecord( dev, &emr.emr ) ? hPal : 0; }
/*********************************************************************** * EMFDRV_SelectBrush */ HBRUSH EMFDRV_SelectBrush( PHYSDEV dev, HBRUSH hBrush, HBITMAP bitmap, const BITMAPINFO *info, void *bits, UINT usage ) { EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev; EMRSELECTOBJECT emr; DWORD index; int i; if (physDev->restoring) return hBrush; /* don't output SelectObject records during RestoreDC */ /* If the object is a stock brush object, do not need to create it. * See definitions in wingdi.h for range of stock brushes. * We do however have to handle setting the higher order bit to * designate that this is a stock object. */ for (i = WHITE_BRUSH; i <= DC_BRUSH; i++) { if (hBrush == GetStockObject(i)) { index = i | 0x80000000; goto found; } } if((index = EMFDRV_FindObject(dev, hBrush)) != 0) goto found; if (!(index = EMFDRV_CreateBrushIndirect(dev, hBrush ))) return 0; GDI_hdc_using_object(hBrush, dev->hdc); found: emr.emr.iType = EMR_SELECTOBJECT; emr.emr.nSize = sizeof(emr); emr.ihObject = index; return EMFDRV_WriteRecord( dev, &emr.emr ) ? hBrush : 0; }
/*********************************************************************** * MFDRV_SelectBrush */ HBRUSH MFDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush ) { INT16 index; index = MFDRV_FindObject(dev, hbrush); if( index < 0 ) { index = MFDRV_CreateBrushIndirect( dev, hbrush ); if( index < 0 ) return 0; GDI_hdc_using_object(hbrush, dev->hdc); } return MFDRV_SelectObject( dev, index ) ? hbrush : 0; }
/*********************************************************************** * MFDRV_SelectBrush */ HBRUSH MFDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap, const BITMAPINFO *info, void *bits, UINT usage ) { INT16 index; index = MFDRV_FindObject(dev, hbrush); if( index < 0 ) { index = MFDRV_CreateBrushIndirect( dev, hbrush ); if( index < 0 ) return 0; GDI_hdc_using_object(hbrush, dev->hdc); } return MFDRV_SelectObject( dev, index ) ? hbrush : 0; }
/*********************************************************************** * MFDRV_SelectBrush */ HBRUSH MFDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush ) { METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dev; INT16 index; index = MFDRV_FindObject(dev, hbrush); if( index < 0 ) { index = MFDRV_CreateBrushIndirect( dev, hbrush ); if( index < 0 ) return 0; GDI_hdc_using_object(hbrush, physDev->hdc); } return MFDRV_SelectObject( dev, index ) ? hbrush : HGDI_ERROR; }
/*********************************************************************** * MFDRV_SelectFont */ HFONT MFDRV_SelectFont( PHYSDEV dev, HFONT hfont ) { LOGFONTW font; INT16 index; index = MFDRV_FindObject(dev, hfont); if( index < 0 ) { if (!GetObjectW( hfont, sizeof(font), &font )) return 0; index = MFDRV_CreateFontIndirect(dev, hfont, &font); if( index < 0 ) return 0; GDI_hdc_using_object(hfont, dev->hdc); } return MFDRV_SelectObject( dev, index ) ? hfont : 0; }
/****************************************************************** * EMFDRV_SetDCBrushColor */ COLORREF EMFDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color ) { EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev; EMRSELECTOBJECT emr; DWORD index; if (GetCurrentObject( dev->hdc, OBJ_BRUSH ) != GetStockObject( DC_BRUSH )) return color; if (physDev->dc_brush) DeleteObject( physDev->dc_brush ); if (!(physDev->dc_brush = CreateSolidBrush( color ))) return CLR_INVALID; if (!(index = EMFDRV_CreateBrushIndirect(dev, physDev->dc_brush ))) return CLR_INVALID; GDI_hdc_using_object( physDev->dc_brush, dev->hdc ); emr.emr.iType = EMR_SELECTOBJECT; emr.emr.nSize = sizeof(emr); emr.ihObject = index; return EMFDRV_WriteRecord( dev, &emr.emr ) ? color : CLR_INVALID; }
/*********************************************************************** * MFDRV_SelectPen */ HPEN MFDRV_SelectPen( PHYSDEV dev, HPEN hpen ) { METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dev; LOGPEN16 logpen; INT16 index; index = MFDRV_FindObject(dev, hpen); if( index < 0 ) { /* must be an extended pen */ INT size = GetObjectW( hpen, 0, NULL ); if (!size) return 0; if (size == sizeof(LOGPEN)) { LOGPEN pen; GetObjectW( hpen, sizeof(pen), &pen ); logpen.lopnStyle = pen.lopnStyle; logpen.lopnWidth.x = pen.lopnWidth.x; logpen.lopnWidth.y = pen.lopnWidth.y; logpen.lopnColor = pen.lopnColor; } else /* must be an extended pen */ { EXTLOGPEN *elp = HeapAlloc( GetProcessHeap(), 0, size ); GetObjectW( hpen, size, elp ); /* FIXME: add support for user style pens */ logpen.lopnStyle = elp->elpPenStyle; logpen.lopnWidth.x = elp->elpWidth; logpen.lopnWidth.y = 0; logpen.lopnColor = elp->elpColor; HeapFree( GetProcessHeap(), 0, elp ); } index = MFDRV_CreatePenIndirect( dev, hpen, &logpen ); if( index < 0 ) return 0; GDI_hdc_using_object(hpen, physDev->hdc); } return MFDRV_SelectObject( dev, index ) ? hpen : HGDI_ERROR; }
/****************************************************************** * EMFDRV_SetDCPenColor */ COLORREF EMFDRV_SetDCPenColor( PHYSDEV dev, COLORREF color ) { EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev; EMRSELECTOBJECT emr; DWORD index; LOGPEN logpen = { PS_SOLID, { 0, 0 }, color }; if (GetCurrentObject( dev->hdc, OBJ_PEN ) != GetStockObject( DC_PEN )) return color; if (physDev->dc_pen) DeleteObject( physDev->dc_pen ); if (!(physDev->dc_pen = CreatePenIndirect( &logpen ))) return CLR_INVALID; if (!(index = EMFDRV_CreatePenIndirect(dev, physDev->dc_pen))) return CLR_INVALID; GDI_hdc_using_object( physDev->dc_pen, dev->hdc ); emr.emr.iType = EMR_SELECTOBJECT; emr.emr.nSize = sizeof(emr); emr.ihObject = index; return EMFDRV_WriteRecord( dev, &emr.emr ) ? color : CLR_INVALID; }
/*********************************************************************** * MFDRV_SelectFont */ HFONT MFDRV_SelectFont( PHYSDEV dev, HFONT hfont, HANDLE gdiFont ) { METAFILEDRV_PDEVICE *physDev = (METAFILEDRV_PDEVICE *)dev; LOGFONTW font; INT16 index; index = MFDRV_FindObject(dev, hfont); if( index < 0 ) { if (!GetObjectW( hfont, sizeof(font), &font )) return HGDI_ERROR; index = MFDRV_CreateFontIndirect(dev, hfont, &font); if( index < 0 ) return HGDI_ERROR; GDI_hdc_using_object(hfont, physDev->hdc); } return MFDRV_SelectObject( dev, index ) ? hfont : HGDI_ERROR; }
/*********************************************************************** * EMFDRV_SelectFont */ HFONT EMFDRV_SelectFont( PHYSDEV dev, HFONT hFont, UINT *aa_flags ) { EMFDRV_PDEVICE *physDev = get_emf_physdev( dev ); EMRSELECTOBJECT emr; DWORD index; int i; if (physDev->restoring) goto done; /* don't output SelectObject records during RestoreDC */ /* If the object is a stock font object, do not need to create it. * See definitions in wingdi.h for range of stock fonts. * We do however have to handle setting the higher order bit to * designate that this is a stock object. */ for (i = OEM_FIXED_FONT; i <= DEFAULT_GUI_FONT; i++) { if (i != DEFAULT_PALETTE && hFont == GetStockObject(i)) { index = i | 0x80000000; goto found; } } if((index = EMFDRV_FindObject(dev, hFont)) != 0) goto found; if (!(index = EMFDRV_CreateFontIndirect(dev, hFont ))) return 0; GDI_hdc_using_object(hFont, dev->hdc); found: emr.emr.iType = EMR_SELECTOBJECT; emr.emr.nSize = sizeof(emr); emr.ihObject = index; if(!EMFDRV_WriteRecord( dev, &emr.emr )) return 0; done: *aa_flags = GGO_BITMAP; /* no point in anti-aliasing on metafiles */ dev = GET_NEXT_PHYSDEV( dev, pSelectFont ); dev->funcs->pSelectFont( dev, hFont, aa_flags ); return hFont; }
/*********************************************************************** * EMFDRV_SelectFont */ HFONT CDECL EMFDRV_SelectFont( PHYSDEV dev, HFONT hFont, HANDLE gdiFont ) { EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev; EMRSELECTOBJECT emr; DWORD index; int i; if (physDev->restoring) return 0; /* don't output SelectObject records during RestoreDC */ /* If the object is a stock font object, do not need to create it. * See definitions in wingdi.h for range of stock fonts. * We do however have to handle setting the higher order bit to * designate that this is a stock object. */ for (i = OEM_FIXED_FONT; i <= DEFAULT_GUI_FONT; i++) { if (i != DEFAULT_PALETTE && hFont == GetStockObject(i)) { index = i | 0x80000000; goto found; } } if((index = EMFDRV_FindObject(dev, hFont)) != 0) goto found; if (!(index = EMFDRV_CreateFontIndirect(dev, hFont ))) return HGDI_ERROR; GDI_hdc_using_object(hFont, physDev->hdc); found: emr.emr.iType = EMR_SELECTOBJECT; emr.emr.nSize = sizeof(emr); emr.ihObject = index; if(!EMFDRV_WriteRecord( dev, &emr.emr )) return HGDI_ERROR; return 0; }