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



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

def align(direction)
  case direction
  when "<" then @halign = GroupLayout::Alignment::LEADING
  when ">" then @halign = GroupLayout::Alignment::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



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

def expand
  @max = Short::MAX_VALUE
end

#finished(error) ⇒ Object



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

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
73
# File 'lib/profligacy/lel.rb', line 62

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

  if component
    # add it in
    @vertical.addComponent(component, @valign, GroupLayout::DEFAULT_SIZE, @height, @max)
    h.addComponent(component, @halign, 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.createParallelGroup
end

#rowObject



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

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

#setheight(height) ⇒ Object



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

def setheight(height)
  @height = height
end

#setwidth(width) ⇒ Object



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

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::Alignment::LEADING
  when "." then @valign = GroupLayout::Alignment::TRAILING
  else
    raise "Invalid Vertical Alignment: #{dir}"
  end
end