gdi32: Use get_dc_attr in SetTextAlign.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-07-26 23:29:36 +02:00 committed by Alexandre Julliard
parent e4502cff81
commit a81d0b97cb
10 changed files with 67 additions and 32 deletions

View File

@ -988,30 +988,6 @@ COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
}
/***********************************************************************
* SetTextAlign (GDI32.@)
*/
UINT WINAPI SetTextAlign( HDC hdc, UINT align )
{
UINT ret = GDI_ERROR;
DC *dc = get_dc_ptr( hdc );
TRACE("hdc=%p align=%d\n", hdc, align);
if (dc)
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetTextAlign );
align = physdev->funcs->pSetTextAlign( physdev, align );
if (align != GDI_ERROR)
{
ret = dc->attr->text_align;
dc->attr->text_align = align;
}
release_dc_ptr( dc );
}
return ret;
}
/***********************************************************************
* GetDCOrgEx (GDI32.@)
*/

View File

@ -61,13 +61,13 @@ BOOL CDECL EMFDRV_RestoreDC( PHYSDEV dev, INT level )
return ret;
}
UINT CDECL EMFDRV_SetTextAlign( PHYSDEV dev, UINT align )
BOOL EMFDC_SetTextAlign( DC_ATTR *dc_attr, UINT align )
{
EMRSETTEXTALIGN emr;
emr.emr.iType = EMR_SETTEXTALIGN;
emr.emr.nSize = sizeof(emr);
emr.iMode = align;
return EMFDRV_WriteRecord( dev, &emr.emr ) ? align : GDI_ERROR;
return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr );
}
BOOL CDECL EMFDRV_SetTextJustification(PHYSDEV dev, INT nBreakExtra, INT nBreakCount)

View File

@ -128,7 +128,6 @@ extern COLORREF CDECL EMFDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color
extern INT CDECL EMFDRV_SetPolyFillMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
extern INT CDECL EMFDRV_SetROP2( PHYSDEV dev, INT rop ) DECLSPEC_HIDDEN;
extern INT CDECL EMFDRV_SetStretchBltMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
extern UINT CDECL EMFDRV_SetTextAlign( PHYSDEV dev, UINT align ) DECLSPEC_HIDDEN;
extern COLORREF CDECL EMFDRV_SetTextColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_SetTextJustification( PHYSDEV dev, INT nBreakExtra, INT nBreakCount ) DECLSPEC_HIDDEN;
extern BOOL CDECL EMFDRV_SetViewportExtEx( PHYSDEV dev, INT x, INT y, SIZE *size ) DECLSPEC_HIDDEN;

View File

@ -144,7 +144,7 @@ static const struct gdi_dc_funcs emfdrv_driver =
EMFDRV_SetROP2, /* pSetROP2 */
NULL, /* pSetRelAbs */
EMFDRV_SetStretchBltMode, /* pSetStretchBltMode */
EMFDRV_SetTextAlign, /* pSetTextAlign */
NULL, /* pSetTextAlign */
NULL, /* pSetTextCharacterExtra */
EMFDRV_SetTextColor, /* pSetTextColor */
EMFDRV_SetTextJustification, /* pSetTextJustification */

View File

@ -67,6 +67,7 @@ extern BOOL METADC_Rectangle( HDC hdc, INT left, INT top, INT right, INT bottom)
extern BOOL METADC_RoundRect( HDC hdc, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetPixel( HDC hdc, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL METADC_SetTextAlign( HDC hdc, UINT align ) DECLSPEC_HIDDEN;
/* enhanced metafiles */
extern BOOL EMFDC_AbortPath( DC_ATTR *dc_attr ) DECLSPEC_HIDDEN;
@ -109,5 +110,6 @@ extern BOOL EMFDC_Rectangle( DC_ATTR *dc_attr, INT left, INT top, INT right,
extern BOOL EMFDC_RoundRect( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetPixel( DC_ATTR *dc_attr, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL EMFDC_SetTextAlign( DC_ATTR *dc_attr, UINT align ) DECLSPEC_HIDDEN;
#endif /* __WINE_GDI_PRIVATE_H */

View File

@ -46,6 +46,25 @@ UINT WINAPI GetTextAlign( HDC hdc )
return dc_attr ? dc_attr->text_align : 0;
}
/***********************************************************************
* SetTextAlign (GDI32.@)
*/
UINT WINAPI SetTextAlign( HDC hdc, UINT align )
{
DC_ATTR *dc_attr;
UINT ret;
TRACE("hdc=%p align=%d\n", hdc, align);
if (is_meta_dc( hdc )) return METADC_SetTextAlign( hdc, align );
if (!(dc_attr = get_dc_attr( hdc ))) return GDI_ERROR;
if (dc_attr->emf && !EMFDC_SetTextAlign( dc_attr, align )) return GDI_ERROR;
ret = dc_attr->text_align;
dc_attr->text_align = align;
return ret;
}
/***********************************************************************
* GetCurrentPositionEx (GDI32.@)
*/

View File

@ -30,9 +30,9 @@ BOOL CDECL MFDRV_RestoreDC( PHYSDEV dev, INT level )
return MFDRV_MetaParam1( dev, META_RESTOREDC, level );
}
UINT CDECL MFDRV_SetTextAlign( PHYSDEV dev, UINT align )
BOOL METADC_SetTextAlign( HDC hdc, UINT align )
{
return MFDRV_MetaParam2( dev, META_SETTEXTALIGN, HIWORD(align), LOWORD(align)) ? align : GDI_ERROR;
return metadc_param2( hdc, META_SETTEXTALIGN, HIWORD(align), LOWORD(align) );
}
INT CDECL MFDRV_SetBkMode( PHYSDEV dev, INT mode )

View File

@ -207,7 +207,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs =
MFDRV_SetROP2, /* pSetROP2 */
MFDRV_SetRelAbs, /* pSetRelAbs */
MFDRV_SetStretchBltMode, /* pSetStretchBltMode */
MFDRV_SetTextAlign, /* pSetTextAlign */
NULL, /* pSetTextAlign */
MFDRV_SetTextCharacterExtra, /* pSetTextCharacterExtra */
MFDRV_SetTextColor, /* pSetTextColor */
MFDRV_SetTextJustification, /* pSetTextJustification */

View File

@ -115,7 +115,6 @@ extern INT CDECL MFDRV_SetPolyFillMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN
extern INT CDECL MFDRV_SetROP2( PHYSDEV dev, INT rop ) DECLSPEC_HIDDEN;
extern INT CDECL MFDRV_SetRelAbs( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
extern INT CDECL MFDRV_SetStretchBltMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN;
extern UINT CDECL MFDRV_SetTextAlign( PHYSDEV dev, UINT align ) DECLSPEC_HIDDEN;
extern INT CDECL MFDRV_SetTextCharacterExtra( PHYSDEV dev, INT extra ) DECLSPEC_HIDDEN;
extern COLORREF CDECL MFDRV_SetTextColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL CDECL MFDRV_SetTextJustification( PHYSDEV dev, INT extra, INT breaks ) DECLSPEC_HIDDEN;

View File

@ -3113,6 +3113,25 @@ static void test_mf_SetPixel(void)
DeleteMetaFile(mf);
}
static void test_mf_attrs(void)
{
HMETAFILE mf;
UINT attr;
HDC hdc;
hdc = CreateMetaFileW(NULL);
ok(hdc != 0, "CreateEnhMetaFile failed\n");
attr = SetTextAlign(hdc, TA_BOTTOM);
ok(attr == TRUE, "attr = %x\n", attr);
attr = SetTextAlign(hdc, TA_TOP);
ok(attr == TRUE, "attr = %x\n", attr);
mf = CloseMetaFile(hdc);
ok(mf != 0, "CloseEnhMetaFile failed\n");
DeleteMetaFile(mf);
}
static void test_enhmetafile_file(void)
{
char temp_path[MAX_PATH];
@ -3247,6 +3266,25 @@ static void test_emf_SetPixel(void)
DeleteEnhMetaFile(emf);
}
static void test_emf_attrs(void)
{
HENHMETAFILE mf;
UINT attr;
HDC hdc;
hdc = CreateEnhMetaFileW(NULL, NULL, NULL, NULL);
ok(hdc != 0, "CreateEnhMetaFile failed\n");
attr = SetTextAlign(hdc, TA_BOTTOM);
ok(attr == 0, "attr = %x\n", attr);
attr = SetTextAlign(hdc, TA_TOP);
ok(attr == TA_BOTTOM, "attr = %x\n", attr);
mf = CloseEnhMetaFile(hdc);
ok(mf != 0, "CloseEnhMetaFile failed\n");
DeleteEnhMetaFile(mf);
}
static void test_CopyMetaFile(void)
{
HDC hdcMetafile;
@ -6387,6 +6425,7 @@ START_TEST(metafile)
test_emf_text_extents();
test_enhmetafile_file();
test_emf_SetPixel();
test_emf_attrs();
/* For win-format metafiles (mfdrv) */
test_mf_SaveDC();
@ -6403,6 +6442,7 @@ START_TEST(metafile)
test_metafile_file();
test_mf_SetPixel();
test_mf_FloodFill();
test_mf_attrs();
/* For metafile conversions */
test_mf_conversions();