class PPCurses::RadioButtonGroup
Attributes
current_option[RW]
selected[RW]
Public Class Methods
new( label, options )
click to toggle source
label : a label for the radio button group options: an array of strings
# File lib/ppcurses/form/radio_button_group.rb, line 16 def initialize( label, options ) @label = label @options = options @current_option = 0 end
Public Instance Methods
clear()
click to toggle source
# File lib/ppcurses/form/radio_button_group.rb, line 53 def clear @current_option = 0 end
height()
click to toggle source
# File lib/ppcurses/form/radio_button_group.rb, line 49 def height 1 end
key_down( key )
click to toggle source
# File lib/ppcurses/form/radio_button_group.rb, line 37 def key_down( key ) if key == KEY_LEFT then @current_option = @current_option-1 end if key == KEY_RIGHT then @current_option = @current_option+1 end if @current_option < 0 then @current_option = @options.length-1 end if @current_option > @options.length-1 then @current_option = 0 end end
set_curs_pos(screen)
click to toggle source
# File lib/ppcurses/form/radio_button_group.rb, line 45 def set_curs_pos(screen) Curses.curs_set(INVISIBLE) end
show(screen)
click to toggle source
# File lib/ppcurses/form/radio_button_group.rb, line 23 def show(screen) screen.attron(Curses::A_REVERSE) if @selected screen.addstr(" #{@label}:") screen.attroff(Curses::A_REVERSE) if @selected @options.each_with_index do |option, index| if index == @current_option screen.addstr(" #{option} #{RADIO_SELECTED} ") else screen.addstr(" #{option} #{RADIO_NOT_SELECTED} ") end end end