Class: RubyCurses::CheckBox

Inherits:
ToggleButton show all
Defined in:
lib/rbcurse/rwidget.rb

Overview

A checkbox, may be selected or unselected TODO hotkey should work here too.

Constant Summary

Constants included from Io

Io::ERROR_COLOR_PAIR, Io::FOOTER_COLOR_PAIR, Io::LINEONE, Io::MAIN_WINDOW_COLOR_PAIR

Instance Attribute Summary

Attributes inherited from Widget

#col_offset, #cols_panned, #config, #curpos, #ext_col_offset, #ext_row_offset, #form, #id, #parent_component, #row_offset, #rows_panned, #should_create_buffer, #state

Instance Method Summary collapse

Methods inherited from ToggleButton

#checked, #checked?, #fire, #handle_key, #toggle

Methods inherited from Button

#OLDunderline, #action, #bind_hotkey, button_layout, #command, #fire, #handle_key, #mnemonic, #repaint, #text

Methods inherited from Widget

#OLDbind_key, #buffer_to_screen, #buffer_to_window, #create_buffer, #destroy, #destroy_buffer, #focus, #get_buffer, #get_color, #get_preferred_size, #handle_key, #height, #height=, #hide, #init_vars, #is_double_buffered?, #modified?, #move, #on_enter, #on_leave, #override_graphic, #printstring, #process_key, #remove, #repaint, #repaint_all, #repaint_required, #rowcol, #safe_create_buffer, #set_buffer_modified, #set_buffering, #set_form, #set_form_col, #set_form_row, #set_modified, #setformrowcol, #setrowcol, #show, #text_variable, #unbind_key, #width, #width=

Methods included from Io

#askchoice, #askyesno, #askyesnocancel, #clear_error, #clear_this, #get_string, #newaskyesno, #old_print_header, #old_print_top_right, #print_action, #print_error, #print_footer_help, #print_header, #print_headers, #print_help, #print_help_page, #print_in_middle, #print_key_labels, #print_key_labels_row, #print_screen_labels, #print_status, #print_this, #print_top_right, #rbgetstr

Methods included from Utils

#_process_key, #bind_key, #clean_string!, #get_color, #keycode_tos, #repeatm, #wrap_text

Methods included from ConfigSetup

#cget, #config_setup, #configure, #variable_set

Methods included from EventHandler

#bind, #fire_handler, #fire_property_change

Methods included from DSL

#OLD_method_missing

Constructor Details

#initialize(form, config = {}, &block) ⇒ CheckBox

if a variable has been defined, off and on value will be set in it (default 0,1)



2489
2490
2491
2492
# File 'lib/rbcurse/rwidget.rb', line 2489

def initialize form, config={}, &block
  @surround_chars = ['[', ']']    # 2008-12-23 23:16 added space in Button so overriding
  super
end

Instance Method Details

#getvalueObject



2493
2494
2495
# File 'lib/rbcurse/rwidget.rb', line 2493

def getvalue
  @value 
end

#getvalue_for_paintObject



2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
# File 'lib/rbcurse/rwidget.rb', line 2497

def getvalue_for_paint
  buttontext = getvalue() ? "X" : " "
  dtext = @display_length.nil? ? @text : "%-*s" % [@display_length, @text]
  dtext = "" if @text.nil?  # added 2009-01-13 00:41 since cbcellrenderer prints no text
  if @align_right
    @text_offset = 0
    @col_offset = dtext.length + @surround_chars[0].length + 1
    return "#{dtext} " + @surround_chars[0] + buttontext + @surround_chars[1] 
  else
    pretext = @surround_chars[0] + buttontext + @surround_chars[1] 
    @text_offset = pretext.length + 1
    @col_offset = @surround_chars[0].length
    #@surround_chars[0] + buttontext + @surround_chars[1] + " #{@text}"
    return pretext + " #{dtext}"
  end
end