ME_Style *ME_ApplyStyle(ME_Style *sSrc, CHARFORMAT2W *style) { CHARFORMAT2W styledata; ME_Style *s = ME_MakeStyle(&sSrc->fmt); style = ME_ToCF2W(&styledata, style); COPY_STYLE_ITEM(CFM_ANIMATION, bAnimation); COPY_STYLE_ITEM(CFM_BACKCOLOR, crBackColor); COPY_STYLE_ITEM(CFM_CHARSET, bCharSet); COPY_STYLE_ITEM(CFM_COLOR, crTextColor); COPY_STYLE_ITEM_MEMCPY(CFM_FACE, szFaceName); COPY_STYLE_ITEM(CFM_KERNING, wKerning); COPY_STYLE_ITEM(CFM_LCID, lcid); COPY_STYLE_ITEM(CFM_OFFSET, yOffset); COPY_STYLE_ITEM(CFM_REVAUTHOR, bRevAuthor); COPY_STYLE_ITEM(CFM_SIZE, yHeight); COPY_STYLE_ITEM(CFM_SPACING, sSpacing); COPY_STYLE_ITEM(CFM_STYLE, sStyle); COPY_STYLE_ITEM(CFM_UNDERLINETYPE, bUnderlineType); COPY_STYLE_ITEM(CFM_WEIGHT, wWeight); s->fmt.dwEffects &= ~(style->dwMask); s->fmt.dwEffects |= style->dwEffects & style->dwMask; s->fmt.dwMask |= style->dwMask; if (style->dwMask & CFM_COLOR) { if (style->dwEffects & CFE_AUTOCOLOR) s->fmt.dwEffects |= CFE_AUTOCOLOR; else s->fmt.dwEffects &= ~CFE_AUTOCOLOR; } return s; }
ME_Style *ME_ApplyStyle(ME_Style *sSrc, CHARFORMAT2W *style) { ME_Style *s = ME_MakeStyle(&sSrc->fmt); assert(style->cbSize == sizeof(CHARFORMAT2W)); COPY_STYLE_ITEM(CFM_ANIMATION, bAnimation); COPY_STYLE_ITEM(CFM_BACKCOLOR, crBackColor); COPY_STYLE_ITEM(CFM_CHARSET, bCharSet); COPY_STYLE_ITEM(CFM_COLOR, crTextColor); COPY_STYLE_ITEM_MEMCPY(CFM_FACE, szFaceName); COPY_STYLE_ITEM(CFM_KERNING, wKerning); COPY_STYLE_ITEM(CFM_LCID, lcid); COPY_STYLE_ITEM(CFM_OFFSET, yOffset); COPY_STYLE_ITEM(CFM_REVAUTHOR, bRevAuthor); if (style->dwMask & CFM_SIZE) { s->fmt.dwMask |= CFM_SIZE; s->fmt.yHeight = min(style->yHeight, yHeightCharPtsMost * 20); } COPY_STYLE_ITEM(CFM_SPACING, sSpacing); COPY_STYLE_ITEM(CFM_STYLE, sStyle); COPY_STYLE_ITEM(CFM_UNDERLINETYPE, bUnderlineType); COPY_STYLE_ITEM(CFM_WEIGHT, wWeight); /* FIXME: this is not documented this way, but that's the more logical */ COPY_STYLE_ITEM(CFM_FACE, bPitchAndFamily); s->fmt.dwEffects &= ~(style->dwMask); s->fmt.dwEffects |= style->dwEffects & style->dwMask; s->fmt.dwMask |= style->dwMask; if (style->dwMask & CFM_COLOR) { if (style->dwEffects & CFE_AUTOCOLOR) s->fmt.dwEffects |= CFE_AUTOCOLOR; else s->fmt.dwEffects &= ~CFE_AUTOCOLOR; } if (style->dwMask & CFM_UNDERLINE) { s->fmt.dwMask |= CFM_UNDERLINETYPE; s->fmt.bUnderlineType = (style->dwEffects & CFM_UNDERLINE) ? CFU_CF1UNDERLINE : CFU_UNDERLINENONE; } if (style->dwMask & CFM_BOLD && !(style->dwMask & CFM_WEIGHT)) { s->fmt.wWeight = (style->dwEffects & CFE_BOLD) ? FW_BOLD : FW_NORMAL; } else if (style->dwMask & CFM_WEIGHT && !(style->dwMask & CFM_BOLD)) { if (style->wWeight > FW_NORMAL) s->fmt.dwEffects |= CFE_BOLD; else s->fmt.dwEffects &= ~CFE_BOLD; } return s; }
ME_Style *ME_ApplyStyle(ME_Style *sSrc, CHARFORMAT2W *style) { CHARFORMAT2W styledata; ME_Style *s = ME_MakeStyle(&sSrc->fmt); style = ME_ToCF2W(&styledata, style); COPY_STYLE_ITEM(CFM_ANIMATION, bAnimation); COPY_STYLE_ITEM(CFM_BACKCOLOR, crBackColor); COPY_STYLE_ITEM(CFM_CHARSET, bCharSet); COPY_STYLE_ITEM(CFM_COLOR, crTextColor); COPY_STYLE_ITEM_MEMCPY(CFM_FACE, szFaceName); COPY_STYLE_ITEM(CFM_KERNING, wKerning); COPY_STYLE_ITEM(CFM_LCID, lcid); COPY_STYLE_ITEM(CFM_OFFSET, yOffset); COPY_STYLE_ITEM(CFM_REVAUTHOR, bRevAuthor); COPY_STYLE_ITEM(CFM_SIZE, yHeight); COPY_STYLE_ITEM(CFM_SPACING, sSpacing); COPY_STYLE_ITEM(CFM_STYLE, sStyle); COPY_STYLE_ITEM(CFM_UNDERLINETYPE, bUnderlineType); COPY_STYLE_ITEM(CFM_WEIGHT, wWeight); /* FIXME: this is not documented this way, but that's the more logical */ COPY_STYLE_ITEM(CFM_FACE, bPitchAndFamily); s->fmt.dwEffects &= ~(style->dwMask); s->fmt.dwEffects |= style->dwEffects & style->dwMask; s->fmt.dwMask |= style->dwMask; if (style->dwMask & CFM_COLOR) { if (style->dwEffects & CFE_AUTOCOLOR) s->fmt.dwEffects |= CFE_AUTOCOLOR; else s->fmt.dwEffects &= ~CFE_AUTOCOLOR; } if (style->dwMask & CFM_UNDERLINE) { s->fmt.dwMask |= CFM_UNDERLINETYPE; s->fmt.bUnderlineType = (style->dwEffects & CFM_UNDERLINE) ? CFU_CF1UNDERLINE : CFU_UNDERLINENONE; } return s; }