Class: Profligacy::LELGroupLayout

Inherits:
Object
  • Object
show all
Includes:
Profligacy::LELParser::LELEventListener
Defined in:
lib/profligacy/lel.rb

Instance Method Summary collapse

Constructor Details

#initialize(layout, components) ⇒ LELGroupLayout

Returns a new instance of LELGroupLayout.



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/profligacy/lel.rb', line 30

def initialize(layout, components)
  @layout = layout
  @hgroup = @layout.createSequentialGroup
  @vgroup = @layout.createSequentialGroup
  @vertical = nil
  @horizontals = []
  @components = components

  alignments_reset
  widths_reset
  heights_reset
  horizontals_reset
end

Instance Method Details

#align(direction) ⇒ Object



79
80
81
82
83
84
85
86
# File 'lib/profligacy/lel.rb', line 79

def align(direction)
  case direction
  when "<" then @halign = GroupLayout::LEADING
  when ">" then @halign = GroupLayout::TRAILING
  else
    raise "Invalid Horizontal Alignment: #{direction}"
  end
end

#colObject



44
45
46
# File 'lib/profligacy/lel.rb', line 44

def col
  horizontals_push; alignments_reset ; widths_reset
end

#expandObject



96
97
98
# File 'lib/profligacy/lel.rb', line 96

def expand
  @max = Short::MAX_VALUE
end

#finished(error) ⇒ Object



100
101
102
103
104
105
# File 'lib/profligacy/lel.rb', line 100

def finished(error)
  if !error
    @layout.setHorizontalGroup(@hgroup);
    @layout.setVerticalGroup(@vgroup);
  end
end

#id(name) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/profligacy/lel.rb', line 62

def id(name)
  h = horizontals_cur
  component = @components[name]

  if component
    @vertical.add(@valign, component, GroupLayout::DEFAULT_SIZE, @height, @max)
    h.add(@halign, component, GroupLayout::DEFAULT_SIZE, @width, @max)
  elsif name != "_"
    raise "Cell named '#{name}' does not have a component set during build."
  end
end

#ltabObject



48
49
50
51
# File 'lib/profligacy/lel.rb', line 48

def ltab
  horizontals_reset
  @vertical = @layout.createBaselineGroup(true, false)
end

#rowObject



74
75
76
77
# File 'lib/profligacy/lel.rb', line 74

def row
  @vgroup.add(@vertical);
  alignments_reset ; widths_reset ; heights_reset
end

#setheight(height) ⇒ Object



92
93
94
# File 'lib/profligacy/lel.rb', line 92

def setheight(height)
  @height = height
end

#setwidth(width) ⇒ Object



88
89
90
# File 'lib/profligacy/lel.rb', line 88

def setwidth(width)
  @width = width
end

#valign(dir) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/profligacy/lel.rb', line 53

def valign(dir)
  case dir
  when "^" then @valign = GroupLayout::LEADING
  when "." then @valign = GroupLayout::TRAILING
  else
    raise "Invalid Vertical Alignment: #{dir}"
  end
end