Huw Davies : riched20: Move y offset calculation to a helper function.
Alexandre Julliard
julliard at winehq.org
Thu Feb 14 15:01:32 CST 2013
Module: wine
Branch: master
Commit: 681a9e1de65b8dd6736fabdaa90bed8af72d046d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=681a9e1de65b8dd6736fabdaa90bed8af72d046d
Author: Huw Davies <huw at codeweavers.com>
Date: Thu Feb 14 14:16:16 2013 +0000
riched20: Move y offset calculation to a helper function.
---
dlls/riched20/paint.c | 31 +++++++++++++++++++++----------
1 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index d7792d4..cd5a427 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -166,6 +166,25 @@ int ME_twips2pointsY(const ME_Context *c, int y)
return y * c->dpi.cy * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
}
+
+static int calc_y_offset( const ME_Context *c, ME_Style *style )
+{
+ int offs = 0, twips = 0;
+
+ if ((style->fmt.dwMask & style->fmt.dwEffects) & CFM_OFFSET)
+ twips = style->fmt.yOffset;
+
+ if ((style->fmt.dwMask & style->fmt.dwEffects) & (CFM_SUPERSCRIPT | CFM_SUBSCRIPT))
+ {
+ if (style->fmt.dwEffects & CFE_SUPERSCRIPT) twips = style->fmt.yHeight/3;
+ if (style->fmt.dwEffects & CFE_SUBSCRIPT) twips = -style->fmt.yHeight/12;
+ }
+
+ if (twips) offs = ME_twips2pointsY( c, twips );
+
+ return offs;
+}
+
static void get_underline_pen( ME_Style *style, COLORREF color, HPEN *pen )
{
*pen = NULL;
@@ -248,7 +267,7 @@ static void ME_DrawTextWithStyle(ME_Context *c, ME_Run *run, int x, int y, LPCWS
HDC hDC = c->hDC;
HGDIOBJ hOldFont;
COLORREF rgbOld;
- int yOffset = 0, yTwipsOffset = 0;
+ int yOffset = 0;
COLORREF rgb;
HPEN hPen = NULL, hOldPen = NULL;
BOOL bHighlightedText = (nSelFrom < nChars && nSelTo >= 0
@@ -263,15 +282,7 @@ static void ME_DrawTextWithStyle(ME_Context *c, ME_Run *run, int x, int y, LPCWS
lpDx = &run->nWidth; /* Make sure underline for tab extends across tab space */
hOldFont = ME_SelectStyleFont(c, run->style);
- if ((run->style->fmt.dwMask & run->style->fmt.dwEffects) & CFM_OFFSET) {
- yTwipsOffset = run->style->fmt.yOffset;
- }
- if ((run->style->fmt.dwMask & run->style->fmt.dwEffects) & (CFM_SUPERSCRIPT | CFM_SUBSCRIPT)) {
- if (run->style->fmt.dwEffects & CFE_SUPERSCRIPT) yTwipsOffset = run->style->fmt.yHeight/3;
- if (run->style->fmt.dwEffects & CFE_SUBSCRIPT) yTwipsOffset = -run->style->fmt.yHeight/12;
- }
- if (yTwipsOffset)
- yOffset = ME_twips2pointsY(c, yTwipsOffset);
+ yOffset = calc_y_offset( c, run->style );
if ((run->style->fmt.dwMask & CFM_LINK) && (run->style->fmt.dwEffects & CFE_LINK))
rgb = RGB(0,0,255);
More information about the wine-cvs
mailing list