From 7805a3f5c32d0e43fafe2fe6991aa38749b478f5 Mon Sep 17 00:00:00 2001 From: HOU Huihua Date: Sun, 18 Nov 2018 13:11:23 +0800 Subject: [PATCH] fixbug: new DC attribute: bidi_flags --- include/gdi.h | 42 ++++++++++++++------------------------ src/include/dc.h | 3 +-- src/newgdi/gdi.c | 8 +++++--- src/newgdi/tabbedtextout.c | 2 +- src/newgdi/textout.c | 2 +- 5 files changed, 23 insertions(+), 34 deletions(-) diff --git a/include/gdi.h b/include/gdi.h index fd2c9842..583b5fc2 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -2009,28 +2009,18 @@ MG_EXPORT void GUIAPI DeleteSecondaryDC (HWND hwnd); #define DC_ATTR_TEXT_ALIGN 10 -#define DC_ATTR_BIDI_ENABLED 11 -#define DC_ATTR_BIDI_FIRSTCH_TYPE 12 - #define BIDI_CHAR_TYPE_INIT 0 - #define BIDI_CHAR_TYPE_LTR 1 - #define BIDI_CHAR_TYPE_RTL 2 +#define DC_ATTR_BIDI_FLAGS 11 #ifdef _MGHAVE_ADV_2DAPI - -#define DC_ATTR_PEN_TYPE 13 -#define DC_ATTR_PEN_CAP_STYLE 14 -#define DC_ATTR_PEN_JOIN_STYLE 15 -#define DC_ATTR_PEN_WIDTH 16 - -#define DC_ATTR_BRUSH_TYPE 17 - -#define NR_DC_ATTRS 18 - -#else - -#define NR_DC_ATTRS 13 - -#endif +# define DC_ATTR_PEN_TYPE 12 +# define DC_ATTR_PEN_CAP_STYLE 13 +# define DC_ATTR_PEN_JOIN_STYLE 14 +# define DC_ATTR_PEN_WIDTH 15 +# define DC_ATTR_BRUSH_TYPE 16 +# define NR_DC_ATTRS 17 +#else /* _MGHAVE_ADV_2DAPI */ +# define NR_DC_ATTRS 12 +#endif /* !_MGHAVE_ADV_2DAPI */ /** @@ -7016,16 +7006,14 @@ MG_EXPORT int GUIAPI GetTabbedTextExtent (HDC hdc, * * \sa GetTextAlign */ -#define SetTextAlign(hdc, ta_flags) \ +#define SetTextAlign(hdc, ta_flags) \ SetDCAttr (hdc, DC_ATTR_TEXT_ALIGN, (DWORD)ta_flags) -#define GetBIDIFlag(hdc) GetDCAttr (hdc, DC_ATTR_BIDI_ENABLED) -#define SetBIDIFlag(hdc, bidi) \ - SetDCAttr (hdc, DC_ATTR_BIDI_ENABLED, (DWORD)bidi) +#define GetBIDIFlags(hdc) \ + GetDCAttr (hdc, DC_ATTR_BIDI_FLAGS) -#define GetBIDIFirstChType(hdc) GetDCAttr (hdc, DC_ATTR_BIDI_FIRSTCH_TYPE) -#define SetBIDIFirstChType(hdc, type) \ - SetDCAttr (hdc, DC_ATTR_BIDI_FIRSTCH_TYPE, (DWORD)type) +#define SetBIDIFlags(hdc, bidi_flags) \ + SetDCAttr (hdc, DC_ATTR_BIDI_FLAGS, (DWORD)bidi) /** * \fn int GUIAPI TextOutLen (HDC hdc, int x, int y, \ diff --git a/src/include/dc.h b/src/include/dc.h index fa8b36ae..fc2a0991 100644 --- a/src/include/dc.h +++ b/src/include/dc.h @@ -166,8 +166,7 @@ struct tagDC int ta_flags; /* Text alignment flags */ - int bidi_flag; /* BIDI enable flag */ - int bidi_firstch_type; /* BIDI first char type */ + int bidi_flags; /* BIDI flags */ #ifdef _MGHAVE_ADV_2DAPI /* pen attributes */ diff --git a/src/newgdi/gdi.c b/src/newgdi/gdi.c index 105863e2..a7bcfd99 100644 --- a/src/newgdi/gdi.c +++ b/src/newgdi/gdi.c @@ -1733,6 +1733,7 @@ static void dc_InitDC (PDC pdc, HWND hWnd, BOOL bIsClient) pdc->mapmode = MM_TEXT; pdc->ta_flags = TA_LEFT | TA_TOP | TA_NOUPDATECP; + pdc->bidi_flags = 0; pdc->ViewOrig.x = pdc->ViewOrig.y = 0; pdc->ViewExtent.x = pdc->ViewExtent.y = 1; @@ -1828,7 +1829,7 @@ static void dc_InitMemDCFrom (PDC pdc, const PDC pdc_ref) /* copy attributes from reference DC */ memcpy (&pdc->bkcolor, &pdc_ref->bkcolor, - sizeof (gal_pixel)*4 + sizeof (int)*7); + sizeof (gal_pixel)*4 + sizeof (int)*8); #ifdef _MGHAVE_ADV_2DAPI memcpy (&pdc->pen_type, &pdc_ref->pen_type, (sizeof(int)*7) + sizeof(POINT) + (sizeof (void*)*3)); @@ -1894,6 +1895,7 @@ static void dc_InitScreenDC (PDC pdc, GAL_Surface *surface) pdc->mapmode = MM_TEXT; pdc->ta_flags = TA_LEFT | TA_TOP | TA_NOUPDATECP; + pdc->bidi_flags = 0; pdc->ViewOrig.x = pdc->ViewOrig.y = 0; pdc->ViewExtent.x = pdc->ViewExtent.y = 1; @@ -3425,8 +3427,8 @@ HWND GUIAPI WindowFromDC (HDC hdc) typedef struct _DCSTATE { GAL_Color bkcolor, pencolor, brushcolor, textcolor; - /* bkmode, tabstop, cExtra, alExtra, blExtra, mapmode, ta_flags */ - char attrs_g1 [sizeof(int)*7]; + /* bkmode, tabstop, cExtra, alExtra, blExtra, mapmode, ta_flags, bidi_flags */ + char attrs_g1 [sizeof(int)*8]; #ifdef _MGHAVE_ADV_2DAPI /* diff --git a/src/newgdi/tabbedtextout.c b/src/newgdi/tabbedtextout.c index edbb51b6..8cad131b 100644 --- a/src/newgdi/tabbedtextout.c +++ b/src/newgdi/tabbedtextout.c @@ -530,7 +530,7 @@ int GUIAPI GetTabbedTextExtentPoint (HDC hdc, const char* text, size->cx = size->cy = 0; /* This function does not support BIDI */ - if (mbc_devfont && pdc->bidi_flag && mbc_devfont->charset_ops->bidi_glyph_type) + if (mbc_devfont && pdc->bidi_flags && mbc_devfont->charset_ops->bidi_glyph_type) return -1; _gdi_start_new_line (pdc); diff --git a/src/newgdi/textout.c b/src/newgdi/textout.c index 116d0b1d..cd258ef4 100644 --- a/src/newgdi/textout.c +++ b/src/newgdi/textout.c @@ -463,7 +463,7 @@ int GUIAPI GetTextExtentPoint (HDC hdc, const char* text, int len, size->cx = size->cy = 0; /* This function does not support BIDI */ - if (mbc_devfont && pdc->bidi_flag && mbc_devfont->charset_ops->bidi_glyph_type) + if (mbc_devfont && pdc->bidi_flags && mbc_devfont->charset_ops->bidi_glyph_type) return -1; _gdi_start_new_line(pdc);