class TaskJuggler::ColumnTable

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.

Attributes

viewWidth[W]

Public Class Methods

new() click to toggle source

Create a new ColumnTable object.

Calls superclass method
# 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

Public Instance Methods

to_html() click to toggle source
Calls superclass method
# 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