Class: EideticRML::Widgets::Page

Inherits:
Container show all
Defined in:
lib/erml_widgets.rb

Direct Known Subclasses

Document

Instance Attribute Summary

Attributes inherited from Container

#children

Attributes inherited from Widget

#disabled, #height_pct, #max_height_pct, #max_width_pct, #parent, #printed, #visible, #width_pct

Instance Method Summary collapse

Methods inherited from Container

#after_layout, #cols, #initialize_copy, #layout, #layout_container, #layout_widget, #leaf?, #leaves, #order, #overflow, #paragraph_style, #preferred_content_height, #preferred_content_width, #preferred_height, #preferred_width, #printed, #rows, #source, #visible

Methods inherited from Widget

#after_layout, #align, #attributes, #before_layout, #border, #border_bottom, #border_left, #border_right, #border_top, #clone, #colspan, #content_bottom, #content_height, #content_left, #content_right, #content_top, #content_width, #default_padding_bottom, #default_padding_left, #default_padding_right, #default_padding_top, #display, #display_for_page, #fill, #font, #font_color, #font_size, #font_style, #font_weight, #has_height?, #has_width?, #id, #initialize_copy, #klass, #layout_widget, #leaf?, #leaves, #max_content_height, #max_height, #max_height_avail, #max_width, #non_content_height, #non_content_width, #origin_x, #origin_y, #padding, #padding_bottom, #padding_left, #padding_right, #padding_top, #path, #position, #preferred_height, #preferred_width, #root, #rowspan, #selector_tag, #shift, #tag, #units, #z_index

Methods included from Support

#from_units, parse_measurement, parse_measurement_pts, #to_units

Constructor Details

#initialize(parent, attrs = {}) ⇒ Page

Returns a new instance of Page.

Raises:

  • (ArgumentError)


1665
1666
1667
1668
1669
1670
1671
# File 'lib/erml_widgets.rb', line 1665

def initialize(parent, attrs={})
  @default_margin = true
  @more = true
  @overflow = true
  super(parent, attrs)
  raise ArgumentError, "Page must be child of Document." unless parent.nil? or parent.is_a?(Document)
end

Instance Method Details

#bottom(units = :pt) ⇒ Object



1673
1674
1675
# File 'lib/erml_widgets.rb', line 1673

def bottom(units=:pt)
  height(units)
end

#compress(value = nil) ⇒ Object



1677
1678
1679
# File 'lib/erml_widgets.rb', line 1677

def compress(value=nil)
  # TODO
end

#crop(value = nil) ⇒ Object



1681
1682
1683
1684
# File 'lib/erml_widgets.rb', line 1681

def crop(value=nil)
  # inherited
  # TODO
end

#height(units = :pt) ⇒ Object



1686
1687
1688
# File 'lib/erml_widgets.rb', line 1686

def height(units=:pt)
  to_units(units, style.height)
end

#left(units = :pt) ⇒ Object



1690
1691
1692
# File 'lib/erml_widgets.rb', line 1690

def left(units=:pt)
  0
end

#margin(value = nil) ⇒ Object



1694
1695
1696
1697
1698
1699
# File 'lib/erml_widgets.rb', line 1694

def margin(value=nil)
  # inherited
  return @default_margin ? parent.margin(value) : super(value) if value.nil? or value.is_a?(Symbol)
  super(value)
  @default_margin = false
end

#margin_bottom(value = nil) ⇒ Object



1716
1717
1718
1719
1720
1721
1722
# File 'lib/erml_widgets.rb', line 1716

def margin_bottom(value=nil)
  # inherited
  return @default_margin ? parent.margin_bottom(value) : super(value) if value.nil? or value.is_a?(Symbol)
  margin(margin) if @default_margin
  super(value)
  @default_margin = false
end

#margin_left(value = nil) ⇒ Object



1724
1725
1726
1727
1728
1729
1730
# File 'lib/erml_widgets.rb', line 1724

def margin_left(value=nil)
  # inherited
  return @default_margin ? parent.margin_left(value) : super(value) if value.nil? or value.is_a?(Symbol)
  margin(margin) if @default_margin
  super(value)
  @default_margin = false
end

#margin_right(value = nil) ⇒ Object



1708
1709
1710
1711
1712
1713
1714
# File 'lib/erml_widgets.rb', line 1708

def margin_right(value=nil)
  # inherited
  return @default_margin ? parent.margin_right(value) : super(value) if value.nil? or value.is_a?(Symbol)
  margin(margin) if @default_margin
  super(value)
  @default_margin = false
end

#margin_top(value = nil) ⇒ Object



1701
1702
1703
1704
1705
1706
# File 'lib/erml_widgets.rb', line 1701

def margin_top(value=nil)
  # inherited
  return @default_margin ? parent.margin_top(value) : super(value) if value.nil? or value.is_a?(Symbol)
  super(value)
  @default_margin = false
end

#more(flag = nil) ⇒ Object



1732
1733
1734
1735
# File 'lib/erml_widgets.rb', line 1732

def more(flag=nil)
  return @more if flag.nil?
  @more = flag
end

#orientation(value = nil) ⇒ Object



1737
1738
1739
1740
1741
# File 'lib/erml_widgets.rb', line 1737

def orientation(value=nil)
  # inherited
  return style.orientation if value.nil?
  style(:copy).orientation(value)
end

#positioned_widgetsObject



1743
1744
1745
# File 'lib/erml_widgets.rb', line 1743

def positioned_widgets
  @positioned_widgets ||= Hash.new(0)
end


1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
# File 'lib/erml_widgets.rb', line 1747

def print(writer)
  root.section_page_no = 0
  while more
    more(false)
    writer.open_page(:page_size => size, :orientation => orientation)
    root.document_page_no += 1
    root.section_page_no += 1
    positioned_widgets.clear
    # $stderr.puts "----before layout widget"
    layout_widget(writer)
    # after_layout
    # $stderr.puts "----before super print"
    super(writer)
    # $stderr.puts "----after super print"
    writer.close_page
    break if positioned_widgets[:static] == 0
  end
end

#right(units = :pt) ⇒ Object



1766
1767
1768
# File 'lib/erml_widgets.rb', line 1766

def right(units=:pt)
  width(units)
end

#root_pageObject



1770
1771
1772
# File 'lib/erml_widgets.rb', line 1770

def root_page
  self
end

#rotate(value = nil) ⇒ Object



1774
1775
1776
1777
# File 'lib/erml_widgets.rb', line 1774

def rotate(value=nil)
  # inherited
  # TODO
end

#size(value = nil) ⇒ Object



1779
1780
1781
1782
1783
# File 'lib/erml_widgets.rb', line 1779

def size(value=nil)
  # inherited
  return style.size if value.nil?
  style(:copy).size(value)
end

#style(value = nil) ⇒ Object



1785
1786
1787
1788
1789
1790
# File 'lib/erml_widgets.rb', line 1785

def style(value=nil)
  # inherited
  return @page_style || parent.page_style if value.nil?
  return @page_style || @page_style = parent.page_style.clone if value == :copy
  @page_style = page_style_for(value)
end

#top(units = :pt) ⇒ Object



1792
1793
1794
# File 'lib/erml_widgets.rb', line 1792

def top(units=:pt)
  0
end

#width(units = :pt) ⇒ Object



1796
1797
1798
# File 'lib/erml_widgets.rb', line 1796

def width(units=:pt)
  to_units(units, style.width)
end