Class: MiniGL::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/minigl/forms.rb

Overview

This class is an abstract ancestor for all form components (Button, ToggleButton, TextField, DropDownList and ProgressBar).

Direct Known Subclasses

Button, DropDownList, Label, ProgressBar, TextField

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, font, text, text_color, disabled_text_color) ⇒ Component

:nodoc:



60
61
62
63
64
65
66
67
68
# File 'lib/minigl/forms.rb', line 60

def initialize(x, y, font, text, text_color, disabled_text_color) # :nodoc:
  @x = x
  @y = y
  @font = font
  @text = text
  @text_color = text_color
  @disabled_text_color = disabled_text_color
  @enabled = @visible = true
end

Instance Attribute Details

#anchorObject (readonly)

:nodoc:



43
44
45
# File 'lib/minigl/forms.rb', line 43

def anchor
  @anchor
end

#anchor_offset_xObject (readonly)

:nodoc:



43
44
45
# File 'lib/minigl/forms.rb', line 43

def anchor_offset_x
  @anchor_offset_x
end

#anchor_offset_yObject (readonly)

:nodoc:



43
44
45
# File 'lib/minigl/forms.rb', line 43

def anchor_offset_y
  @anchor_offset_y
end

#enabledObject

Determines whether the control is enabled, i.e., will process user input.



46
47
48
# File 'lib/minigl/forms.rb', line 46

def enabled
  @enabled
end

#hObject (readonly)

The height of the component



38
39
40
# File 'lib/minigl/forms.rb', line 38

def h
  @h
end

#panelObject

:nodoc:



58
59
60
# File 'lib/minigl/forms.rb', line 58

def panel
  @panel
end

#paramsObject

A container for any parameters to be passed to the code blocks called in response to events of the control (click of a button, change of the text in a text field, etc.). More detail can be found in the constructor for each specific component class.



56
57
58
# File 'lib/minigl/forms.rb', line 56

def params
  @params
end

#textObject (readonly)

The text of the component



41
42
43
# File 'lib/minigl/forms.rb', line 41

def text
  @text
end

#visibleObject

Determines whether the control is visible, i.e., will be drawn in the screen and process user input, if enabled.



50
51
52
# File 'lib/minigl/forms.rb', line 50

def visible
  @visible
end

#wObject (readonly)

The width of the component



35
36
37
# File 'lib/minigl/forms.rb', line 35

def w
  @w
end

#xObject (readonly)

The horizontal coordinate of the component



29
30
31
# File 'lib/minigl/forms.rb', line 29

def x
  @x
end

#yObject (readonly)

The vertical coordinate of the component



32
33
34
# File 'lib/minigl/forms.rb', line 32

def y
  @y
end

Instance Method Details

#set_position(x, y) ⇒ Object

Sets the position of the component. Parameters:

x

The new x coordinate.

y

The new y coordinate.



76
77
78
# File 'lib/minigl/forms.rb', line 76

def set_position(x, y)
  @x = x; @y = y
end

#updateObject

:nodoc:



70
# File 'lib/minigl/forms.rb', line 70

def update; end