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_MakeStyle(CHARFORMAT2W *style) { CHARFORMAT2W styledata; ME_Style *s = ALLOC_OBJ(ME_Style); style = ME_ToCF2W(&styledata, style); memset(s, 0, sizeof(ME_Style)); if (style->cbSize <= sizeof(CHARFORMAT2W)) CopyMemory(&s->fmt, style, style->cbSize); else CopyMemory(&s->fmt, style, sizeof(CHARFORMAT2W)); s->fmt.cbSize = sizeof(CHARFORMAT2W); s->nSequence = -2; s->nRefs = 1; s->hFont = NULL; s->tm.tmAscent = -1; all_refs++; 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; }
void ME_CopyToCF2W(CHARFORMAT2W *to, CHARFORMAT2W *from) { if (ME_ToCF2W(to, from) == from) CopyMemory(to, from, sizeof(*from)); }
void ME_CopyToCF2W(CHARFORMAT2W *to, CHARFORMAT2W *from) { if (ME_ToCF2W(to, from) == from) *to = *from; }