This class is essentially a wrapper around ReportTable that allows us to embed a ReportTable object as a column of another ReportTable object. Both ReportTables must have the same number of lines.
Create a new ColumnTable object.
# File lib/reports/ColumnTable.rb, line 26 26: def initialize 27: super 28: # The user requested width of the column (chart) 29: @viewWidth = nil 30: # The header will have 2 lines. So, use a smaller font. This should match 31: # the font size used for the GanttChart header. 32: @headerFontSize = 10 33: # This is an embedded table. 34: @embedded = true 35: end
# File lib/reports/ColumnTable.rb, line 37 37: def to_html 38: height = 2 * @headerLineHeight + 1 39: @lines.each do |line| 40: # Add line height plus 1 pixel padding 41: height += line.height + 1 42: end 43: 44: # Since we don't know the resulting width of the column, we need to always 45: # add an extra space for the scrollbar. 46: td = XMLElement.new('td', 'rowspan' => "#{2 + @lines.length + 1}", 47: 'style' => 'padding:0px; vertical-align:top;') 48: # Now we generate a 'div' that will contain the nested table. It has a 49: # height that fits all lines but has a maximum width. In case the embedded 50: # table is larger, a scrollbar will appear. We assume that the scrollbar 51: # has a height of SCROLLBARHEIGHT pixels or less. 52: # If there is a user specified with, use it. Otherwise use the 53: # calculated minimum with. 54: width = @viewWidth ? @viewWidth : minWidth 55: td << (scrollDiv = XMLElement.new('div', 'class' => 'tabback', 56: 'style' => 'position:relative; overflow:auto; ' + 57: "width:#{width}px; " + 58: 'margin-top:-1px; margin-bottom:-1px; ' + 59: "height:#{height + SCROLLBARHEIGHT + 2}px;")) 60: 61: scrollDiv << (contentDiv = XMLElement.new('div', 62: 'style' => 'margin: 0px; padding: 0px; position: absolute; top: 0px;' + 63: "left: 0px; width: #{@viewWidth}px; height: #{height}px; ")) 64: contentDiv << super 65: td 66: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.