Stylesheet Development with PTC ALD > Adding PTC ALD Code to Stylesheet Source > Samples > Blocks > Apply Boxing to a Block > Simple boxing
  
Simple boxing
This topic includes some examples on how to create simple rules for a block.
Refer to the para in sect2 in first sect1 in appendix context in the Arbortext-path/samples/ALD/Blocks/Boxing/blockBoxing.xml sample file. The context includes a set of conditions based on the value of the role attribute in the associated stylesheet. Each condition refers to a different property set, which in turn provides a different rule effect.
Each property set specifies a single rule for a block, defined in the rule variable. The rule is always 2pt thick, red, and based on the Solid line style. The only difference between the property sets is the position they set for the rule in relation to the block.
Each property set defines the same method of applying the rule to the block and the same set of block padding instructions. You will need to include these instructions whenever you create a rule:
block.rules.addRule(rule);
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.
The examples below describe code that defines a single identical rule with different positions. The positioning of the rule is specified via constants for the fRule object - SIDE_BOX for all sides or a combination of SIDE_TOP, SIDE_BOTTOM, SIDE_LEFT, and SIDE_RIGHT.
Note that you will find many further examples in the blockboxing.xml sample file.
Draw a simple rule on all sides of a block
role=”tblr” condition
simple boxing property set
var rule = new fRule;
rule.sides = fRule.SIDE_BOX;
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 to draw the rule on all sides of a block.
Draw a simple rule on the right side of a block only
role=”r” condition
simple r property set
var rule = new fRule;
rule.sides = fRule.SIDE_RIGHT;
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_RIGHT constant from the fRule object to draw the rule on the right side of the block only.
Draw a simple rule on the bottom, left, and right sides of a block
role=”blr”
simple blr property set
var rule = new fRule;
rule.sides = fRule.SIDE_BOTTOM + fRule.SIDE_LEFT + fRule.SIDE_RIGHT;
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_BOTTOM, SIDE_LEFT, and SIDE_RIGHT constants from the fRule object to draw the rule on the bottom, left, and right sides of a block.