Class: Luck::Control

Inherits:
Object
  • Object
show all
Defined in:
lib/luck/control.rb

Direct Known Subclasses

Label, ListBox, ProgressBar

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pane, x1, y1, x2, y2, &blck) ⇒ Control

Returns a new instance of Control.



5
6
7
8
9
10
11
12
# File 'lib/luck/control.rb', line 5

def initialize pane, x1, y1, x2, y2, &blck
  @pane = pane
  @display = pane.display
  @x1, @y1 = x1, y1
  @x2, @y2 = x2, y2
  
  instance_eval &blck if blck
end

Instance Attribute Details

#displayObject

Returns the value of attribute display.



3
4
5
# File 'lib/luck/control.rb', line 3

def display
  @display
end

#paneObject

Returns the value of attribute pane.



3
4
5
# File 'lib/luck/control.rb', line 3

def pane
  @pane
end

#x1Object

Returns the value of attribute x1.



3
4
5
# File 'lib/luck/control.rb', line 3

def x1
  @x1
end

#x2Object

Returns the value of attribute x2.



3
4
5
# File 'lib/luck/control.rb', line 3

def x2
  @x2
end

#y1Object

Returns the value of attribute y1.



3
4
5
# File 'lib/luck/control.rb', line 3

def y1
  @y1
end

#y2Object

Returns the value of attribute y2.



3
4
5
# File 'lib/luck/control.rb', line 3

def y2
  @y2
end

Instance Method Details

#focus!Object



14
15
16
# File 'lib/luck/control.rb', line 14

def focus!
  @display.active_control = self
end

#heightObject



35
36
37
# File 'lib/luck/control.rb', line 35

def height
  y2 - y1
end

#widthObject



32
33
34
# File 'lib/luck/control.rb', line 32

def width
  x2 - x1
end