Class: TaskJuggler::ColumnTable
- Inherits:
-
ReportTable
- Object
- ReportTable
- TaskJuggler::ColumnTable
- Defined in:
- lib/taskjuggler/reports/ColumnTable.rb
Overview
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.
Constant Summary
Constants inherited from ReportTable
Instance Attribute Summary collapse
-
#viewWidth ⇒ Object
writeonly
Sets the attribute viewWidth.
Attributes inherited from ReportTable
#auxDir, #embedded, #equiLines, #headerFontSize, #headerLineHeight, #maxIndent, #selfcontained
Instance Method Summary collapse
-
#initialize ⇒ ColumnTable
constructor
Create a new ColumnTable object.
- #to_html ⇒ Object
Methods inherited from ReportTable
#addColumn, #addLine, #lines, #minWidth, #to_csv
Constructor Details
#initialize ⇒ ColumnTable
Create a new ColumnTable object.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/taskjuggler/reports/ColumnTable.rb', line 26 def initialize super # The user requested width of the column (chart) @viewWidth = nil # The header will have 2 lines. So, use a smaller font. This should match # the font size used for the GanttChart header. @headerFontSize = 10 # This is an embedded table. @embedded = true end |
Instance Attribute Details
#viewWidth=(value) ⇒ Object (writeonly)
Sets the attribute viewWidth
23 24 25 |
# File 'lib/taskjuggler/reports/ColumnTable.rb', line 23 def viewWidth=(value) @viewWidth = value end |
Instance Method Details
#to_html ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/taskjuggler/reports/ColumnTable.rb', line 37 def to_html height = 2 * @headerLineHeight + 1 @lines.each do |line| # Add line height plus 1 pixel padding height += line.height + 1 end # Since we don't know the resulting width of the column, we need to always # add an extra space for the scrollbar. td = XMLElement.new('td', 'rowspan' => "#{2 + @lines.length + 1}", 'style' => 'padding:0px; vertical-align:top;') # Now we generate a 'div' that will contain the nested table. It has a # height that fits all lines but has a maximum width. In case the embedded # table is larger, a scrollbar will appear. We assume that the scrollbar # has a height of SCROLLBARHEIGHT pixels or less. # If there is a user specified with, use it. Otherwise use the # calculated minimum with. width = @viewWidth ? @viewWidth : minWidth td << (scrollDiv = XMLElement.new('div', 'class' => 'tabback', 'style' => 'position:relative; overflow:auto; ' + "width:#{width}px; " + 'margin-top:-1px; margin-bottom:-1px; ' + "height:#{height + SCROLLBARHEIGHT + 2}px;")) scrollDiv << (contentDiv = XMLElement.new('div', 'style' => 'margin: 0px; padding: 0px; position: absolute; top: 0px;' + "left: 0px; width: #{@viewWidth}px; height: #{height}px; ")) contentDiv << super td end |