class WhirledPeas::Graphics::ContainerDimensions

Attributes

children_height[R]
children_width[R]
num_cols[R]
num_rows[R]
orig_content_height[R]
orig_content_width[R]
settings[R]

Public Class Methods

new(settings, content_width, content_height, num_cols=1, num_rows=1) click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 6
def initialize(settings, content_width, content_height, num_cols=1, num_rows=1)
  @orig_content_width = content_width
  @orig_content_height = content_height
  @children_width = content_width
  @children_height = content_height
  @num_cols = num_cols
  @num_rows = num_rows
  @settings = settings
end

Public Instance Methods

content_height() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 25
def content_height
  return orig_content_height unless settings.height
  if settings.border_sizing?
    settings.height - outer_border_height - scrollbar_height - padding_height
  else
    settings.height
  end
end
content_width() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 16
def content_width
  return orig_content_width unless settings.width
  if settings.border_sizing?
    settings.width - outer_border_width - scrollbar_width - padding_width
  else
    settings.width
  end
end
grid_height() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 52
def grid_height
  (settings.border.inner_horiz? ? 1 : 0) +
    inner_grid_height +
    (settings.scrollbar.horiz? ? 1 : 0)
end
grid_width() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 40
def grid_width
  (settings.border.inner_vert? ? 1 : 0) +
    inner_grid_width +
    (settings.scrollbar.vert? ? 1 : 0)
end
inner_border_height() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 92
def inner_border_height
  settings.border.inner_horiz? ? 1 : 0
end
inner_border_width() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 88
def inner_border_width
  settings.border.inner_vert? ? 1 : 0
end
inner_grid_height() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 46
def inner_grid_height
  settings.padding.top +
    content_height +
    settings.padding.bottom
end
inner_grid_width() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 34
def inner_grid_width
  settings.padding.left +
    content_width +
    settings.padding.right
end
margin_height() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 76
def margin_height
  settings.margin.top + settings.margin.bottom
end
margin_width() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 72
def margin_width
  settings.margin.left + settings.margin.right
end
outer_border_height() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 84
def outer_border_height
  (settings.border.top? ? 1 : 0) + (settings.border.bottom? ? 1 : 0)
end
outer_border_width() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 80
def outer_border_width
  (settings.border.left? ? 1 : 0) + (settings.border.right? ? 1 : 0)
end
outer_height() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 65
def outer_height
  @outer_height ||= margin_height +
    outer_border_height +
    num_rows * (padding_height + content_height + scrollbar_height) +
    (num_rows - 1) * inner_border_height
end
outer_width() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 58
def outer_width
  @outer_width ||= margin_width +
    outer_border_width +
    num_cols * (padding_width + content_width + scrollbar_width) +
    (num_cols - 1) * inner_border_width
end
padding_height() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 100
def padding_height
  settings.padding.top + settings.padding.bottom
end
padding_width() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 96
def padding_width
  settings.padding.left + settings.padding.right
end
scrollbar_height() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 108
def scrollbar_height
  settings.scrollbar.horiz? ? 1 : 0
end
scrollbar_width() click to toggle source
# File lib/whirled_peas/graphics/container_dimensions.rb, line 104
def scrollbar_width
  settings.scrollbar.vert? ? 1 : 0
end