def draw
rel_point = @point
if @background_color
@document.mask(:fill_color) do
@document.fill_color @background_color
h = borders.include?(:bottom) ?
height - border_width : height + border_width / 2.0
@document.fill_rectangle [rel_point[0] + border_width / 2.0,
rel_point[1] - border_width / 2.0 ],
width - border_width, h
end
end
if @border_width > 0
@document.mask(:line_width) do
@document.line_width = @border_width
@document.mask(:stroke_color) do
@document.stroke_color @border_color if @border_color
if borders.include?(:left)
@document.stroke_line [rel_point[0], rel_point[1] + (@border_width / 2.0)],
[rel_point[0], rel_point[1] - height - @border_width / 2.0 ]
end
if borders.include?(:right)
@document.stroke_line(
[rel_point[0] + width, rel_point[1] + (@border_width / 2.0)],
[rel_point[0] + width, rel_point[1] - height - @border_width / 2.0] )
end
if borders.include?(:top)
@document.stroke_line(
[ rel_point[0] + @border_width / 2.0, rel_point[1] ],
[ rel_point[0] - @border_width / 2.0 + width, rel_point[1] ])
end
if borders.include?(:bottom)
@document.stroke_line [rel_point[0], rel_point[1] - height ],
[rel_point[0] + width, rel_point[1] - height]
end
end
end
borders
end
@document.bounding_box( [@point[0] + @horizontal_padding,
@point[1] - @vertical_padding],
:width => text_area_width,
:height => height - @vertical_padding) do
@document.move_down((@document.font.line_gap - @document.font.descender)/2)
options = {:align => @align, :final_gap => false}
options[:size] = @font_size if @font_size
options[:style] = @font_style if @font_style
@document.mask(:fill_color) do
@document.fill_color @text_color if @text_color
@document.text @text, options
end
end
end