Stylesheet Development with PTC ALD > Adding PTC ALD Code to Stylesheet Source > Samples > Blocks > Apply Boxing to a Block > Rounded Corner Box with a Background Color
Rounded Corner Box with a Background Color
Refer to the para in sect1[3] in chapter context in the Arbortext-path/samples/ALD/Blocks/Boxing/blockBoxing.xml sample file. The context references the rounded boxing with background property set in the associated stylesheet. The relevant code in that property set is given below.
var rule = new fRule;
rule.sides = fRule.SIDE_BOX + fRule.SIDE_NW + fRule.SIDE_NE + fRule.SIDE_SW
+ fRule.SIDE_SE;
rule.radius = "12pt";
rule.thickness = "2pt";
rule.lineColor = "red";
rule.lineStyle = fRuleLine.LINE_SOLID;
Here you have created a new rule based on the fRule object, and set up the variable rule to hold the rule information. You specify the SIDE_BOX constant from the fRule object and the LINE_SOLID constant from the fRuleLine object to draw a box, drawn in the Solid line style, around the contents of a block. You also reference the SIDE_NW, SIDE_NE, SIDE_SW, and SIDE_SE constants from the fRule object to configure a rounded shape for all four corners of the block. You also provide size and color settings for the thickness and lineColor properties of the fRule object, and a measure for the radius (curve) of the rounded corners.
rule.fillColor = "blue";
Here you have provided a color setting for the fillColor property of the fRule object. The background of the box will be shaded in this color.
rule.fillColor is used to ensure that the background color fills the shape defined by the rules. You could use the backgroundColor property for the block if you wanted the color to fill the block itself.
Here you call the addRule() method from the fRules object to apply the rule information contained in the rule variable to a block. Note that block information for any context that references this property set must come from its Structure setting in the Breaks property category in the Arbortext Styler UI. If the context is set as Inline the rule will not be applied.
block.paddingTop = block.paddingBottom = block.paddingLeft
= block.paddingRight = "3pt";
With this phrase you specify that the four padding properties for the fBlock object all share the same value, i.e. 3pt. This setting provides some space between the rule and the block’s content.