Class: ButtonWidget
- Inherits:
-
Object
- Object
- ButtonWidget
- Defined in:
- lib/widget/button-widget.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
Instance Method Summary collapse
- #draw ⇒ Object
- #handle(chr) ⇒ Object
-
#initialize(screen, value, x, y) ⇒ ButtonWidget
constructor
A new instance of ButtonWidget.
Constructor Details
#initialize(screen, value, x, y) ⇒ ButtonWidget
Returns a new instance of ButtonWidget.
4 5 6 7 8 9 10 |
# File 'lib/widget/button-widget.rb', line 4 def initialize(screen, value, x, y) @active = false @screen = screen @value = value @x = x @y = y end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
3 4 5 |
# File 'lib/widget/button-widget.rb', line 3 def active @active end |
Instance Method Details
#draw ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/widget/button-widget.rb', line 20 def draw value = @value if(value.empty?) value = "XXXXX" end @screen.attron Curses::A_BOLD if @active @screen.setpos(@y,@x) @screen.addstr "-"*(2+value.length) @screen.setpos(@y+1,@x) @screen.addstr("|"+value+"|") @screen.setpos(@y+2,@x) @screen.addstr "-"*(2+value.length) @screen.attroff Curses::A_BOLD if @active end |
#handle(chr) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/widget/button-widget.rb', line 12 def handle(chr) if(chr == "\n" || chr == 13) true else false end end |