class PPCurses::DatePicker

Ruby date objects are immutable


09-15-1950 05-04-2015 = May 4th 2015

Constants

DOWN_ARROW

Attributes

date[RW]
selected[RW]

Does the element have focus in the form?

Public Class Methods

new(label, initial_date = Date.today) click to toggle source
# File lib/ppcurses/form/date_picker.rb, line 17
def initialize(label, initial_date = Date.today)
  @label = label
  @display_width = 13
  @date = initial_date      
end

Public Instance Methods

clear() click to toggle source
# File lib/ppcurses/form/date_picker.rb, line 75
def clear
   @date = Date.today
   if  @date_menu.nil? == false
     @date_menu.day = @date 
   end
end
height() click to toggle source
# File lib/ppcurses/form/date_picker.rb, line 35
def height
  1
end
key_down(key) click to toggle source
# File lib/ppcurses/form/date_picker.rb, line 54
def key_down(key)

  if key == ENTER
    
    if  @date_menu.nil?         
      @date_menu = PPCurses::DateMenu.new(@date)
    end

    @date_menu.set_origin(@combo_display_point)

    @date_menu.show
    @date_menu.menu_selection

    if @date_menu.pressed_enter
      @date = @date_menu.day
    end

  end

end
object_value_of_selected_item() click to toggle source

Return Value The object in the receiver's internal item list corresponding to the last item selected from the pop-up list, or nil if no item is selected.

# File lib/ppcurses/form/date_picker.rb, line 46
def object_value_of_selected_item
  if  @options_menu.nil?
    return nil
  end

  @options[@options_menu.selection]
end
set_curs_pos(screen) click to toggle source
# File lib/ppcurses/form/date_picker.rb, line 39
def set_curs_pos(screen)
  screen.curs_set(INVISIBLE)
end
show(screen) click to toggle source
# File lib/ppcurses/form/date_picker.rb, line 24
def show(screen)
  screen.attron(A_REVERSE) if @selected
  screen.addstr("#{@label}:")

  @combo_display_point = screen.cur_point

  screen.attroff(A_REVERSE) if @selected

  screen.addstr(display_string)
end

Protected Instance Methods

display_string() click to toggle source
# File lib/ppcurses/form/date_picker.rb, line 84
def display_string
  " #{@date.month}-#{@date.day}-#{@date.year} #{DOWN_ARROW}"
end