/// <summary> /// Intended for use only by AssembledStylesCache to make derived styles. /// If inheritedOnly is true, only those properties are copied which should be inherited by /// nested boxes. /// </summary> internal AssembledStyles(AssembledStyles basedOn, bool inheritedOnly) { m_styleCache = basedOn.m_styleCache; // all derived styles share it m_chrp = basedOn.m_chrp; m_lineHeight = basedOn.m_lineHeight; m_firstLineIndent = basedOn.m_firstLineIndent; m_styleName = basedOn.m_styleName; RightToLeft = basedOn.RightToLeft; if (inheritedOnly) { SetNonInheritedDefaults(); } else { // copy everything else, too. m_paraAlignment = basedOn.m_paraAlignment; m_borderColor = basedOn.m_borderColor; m_borders = basedOn.m_borders; m_margins = basedOn.m_margins; m_pads = basedOn.m_pads; m_weight = basedOn.m_weight; } }
/// <summary> /// Return an object which, when passed to WithProperties, will return an assembled styles /// with the specified borders. /// Enhance JohnT: may want a mechanism to allow only certain borders to be modified. /// </summary> public static PropSetter BordersSetter(Thickness margins) { var result = new BordersPropSetter(); result.SetToValue = margins; return result; }
void SetNonInheritedDefaults() { // It's better for nested boxes to be treated as transparent, then we don't waste time // repainting their background if it is the same. int clrTrans = (int)FwTextColor.kclrTransparent; m_chrp.clrBack = (uint)clrTrans; m_borderColor = Color.Black; m_margins = Thickness.Default; m_pads = Thickness.Default; m_borders = Thickness.Default; }
/// <summary> /// Return a new styles (or existing canonical one) like the current one but with the specified margins. /// </summary> public AssembledStyles WithBorders(Thickness borders) { // It's arbitrary which of the ktptMargin constants we use. return m_styleCache.GetDerivedStyle(this, (int)FwTextPropType.ktptBorderLeading, borders, (newStyles, w) => newStyles.m_borders = borders); }
/// <summary> /// Return a new styles (or existing canonical one) like the current one but with the specified pads. /// </summary> public AssembledStyles WithPads(Thickness pads) { // It's arbitrary which of the ktptMargin constants we use. return m_styleCache.GetDerivedStyle(this, (int)FwTextPropType.ktptPadLeading, pads, (newStyles, w) => newStyles.m_pads = pads); }
private void ApplyParagraphStyleInfo(IParaStyleInfo paraInfo) { if(paraInfo == null) return; if(paraInfo.Alignment != null && paraInfo.Alignment.ValueIsSet) m_paraAlignment = paraInfo.Alignment.Value; if (paraInfo.LineHeight != null && paraInfo.LineHeight.ValueIsSet) m_lineHeight = paraInfo.LineHeight.Value.m_lineHeight; if (paraInfo.FirstLineIndent != null && paraInfo.FirstLineIndent.ValueIsSet) m_firstLineIndent = paraInfo.FirstLineIndent.Value; int borderLeading = 0; int borderTop = 0; int borderTrailing = 0; int borderBottom = 0; if(paraInfo.BorderColor != null && paraInfo.BorderColor.ValueIsSet) m_borderColor = paraInfo.BorderColor.Value; if (paraInfo.BorderLeading != null && paraInfo.BorderLeading.ValueIsSet) borderLeading = paraInfo.BorderLeading.Value; if (paraInfo.BorderTop != null && paraInfo.BorderTop.ValueIsSet) borderTop = paraInfo.BorderTop.Value; if (paraInfo.BorderTrailing != null && paraInfo.BorderTrailing.ValueIsSet) borderTrailing = paraInfo.BorderTrailing.Value; if (paraInfo.BorderBottom != null && paraInfo.BorderBottom.ValueIsSet) borderBottom = paraInfo.BorderBottom.Value; m_borders = new Thickness(borderLeading, borderTop, borderTrailing, borderBottom); int marginLeading = 0; int marginTop = 0; int marginTrailing = 0; int marginBottom = 0; if (paraInfo.MarginLeading != null && paraInfo.MarginLeading.ValueIsSet) marginLeading = paraInfo.MarginLeading.Value; if (paraInfo.MarginTop != null && paraInfo.MarginTop.ValueIsSet) marginTop = paraInfo.MarginTop.Value; if (paraInfo.MarginTrailing != null && paraInfo.MarginTrailing.ValueIsSet) marginTrailing = paraInfo.MarginTrailing.Value; if (paraInfo.MarginBottom != null && paraInfo.MarginBottom.ValueIsSet) marginBottom = paraInfo.MarginBottom.Value; m_margins = new Thickness(marginLeading, marginTop, marginTrailing, marginBottom); int padLeading = 0; int padTop = 0; int padTrailing = 0; int padBottom = 0; if (paraInfo.PadLeading != null && paraInfo.PadLeading.ValueIsSet) padLeading = paraInfo.PadLeading.Value; if (paraInfo.PadTop != null && paraInfo.PadTop.ValueIsSet) padTop = paraInfo.PadTop.Value; if (paraInfo.PadTrailing != null && paraInfo.PadTrailing.ValueIsSet) padTrailing = paraInfo.PadTrailing.Value; if (paraInfo.PadBottom != null && paraInfo.PadBottom.ValueIsSet) padBottom = paraInfo.PadBottom.Value; m_pads = new Thickness(padLeading, padTop, padTrailing, padBottom); }
public bool Equals(Thickness other) { return other.Leading == Leading && other.Top == Top && other.Trailing == Trailing && other.Bottom == Bottom; }